mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 10:18:38 +00:00
SearchRepositoryByName improvements and unification (#6897)
This commit is contained in:
@@ -170,74 +170,44 @@ func Profile(ctx *context.Context) {
|
||||
}
|
||||
case "stars":
|
||||
ctx.Data["PageIsProfileStarList"] = true
|
||||
if len(keyword) == 0 {
|
||||
repos, err = ctxUser.GetStarredRepos(showPrivate, page, setting.UI.User.RepoPagingNum, orderBy.String())
|
||||
if err != nil {
|
||||
ctx.ServerError("GetStarredRepos", err)
|
||||
return
|
||||
}
|
||||
|
||||
count, err = ctxUser.GetStarredRepoCount(showPrivate)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetStarredRepoCount", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
|
||||
Keyword: keyword,
|
||||
OwnerID: ctxUser.ID,
|
||||
OrderBy: orderBy,
|
||||
Private: showPrivate,
|
||||
Page: page,
|
||||
PageSize: setting.UI.User.RepoPagingNum,
|
||||
Starred: true,
|
||||
Collaborate: util.OptionalBoolFalse,
|
||||
TopicOnly: topicOnly,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchRepositoryByName", err)
|
||||
return
|
||||
}
|
||||
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
|
||||
Keyword: keyword,
|
||||
OrderBy: orderBy,
|
||||
Private: ctx.IsSigned,
|
||||
UserIsAdmin: ctx.IsUserSiteAdmin(),
|
||||
UserID: ctx.Data["SignedUserID"].(int64),
|
||||
Page: page,
|
||||
PageSize: setting.UI.User.RepoPagingNum,
|
||||
StarredByID: ctxUser.ID,
|
||||
Collaborate: util.OptionalBoolFalse,
|
||||
TopicOnly: topicOnly,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchRepositoryByName", err)
|
||||
return
|
||||
}
|
||||
|
||||
total = int(count)
|
||||
default:
|
||||
if len(keyword) == 0 {
|
||||
repos, err = models.GetUserRepositories(ctxUser.ID, showPrivate, page, setting.UI.User.RepoPagingNum, orderBy.String())
|
||||
if err != nil {
|
||||
ctx.ServerError("GetRepositories", err)
|
||||
return
|
||||
}
|
||||
|
||||
if showPrivate {
|
||||
total = ctxUser.NumRepos
|
||||
} else {
|
||||
count, err := models.GetPublicRepositoryCount(ctxUser)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetPublicRepositoryCount", err)
|
||||
return
|
||||
}
|
||||
total = int(count)
|
||||
}
|
||||
} else {
|
||||
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
|
||||
Keyword: keyword,
|
||||
OwnerID: ctxUser.ID,
|
||||
OrderBy: orderBy,
|
||||
Private: showPrivate,
|
||||
Page: page,
|
||||
IsProfile: true,
|
||||
PageSize: setting.UI.User.RepoPagingNum,
|
||||
Collaborate: util.OptionalBoolFalse,
|
||||
TopicOnly: topicOnly,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchRepositoryByName", err)
|
||||
return
|
||||
}
|
||||
|
||||
total = int(count)
|
||||
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
|
||||
Keyword: keyword,
|
||||
OwnerID: ctxUser.ID,
|
||||
OrderBy: orderBy,
|
||||
Private: ctx.IsSigned,
|
||||
UserIsAdmin: ctx.IsUserSiteAdmin(),
|
||||
UserID: ctx.Data["SignedUserID"].(int64),
|
||||
Page: page,
|
||||
IsProfile: true,
|
||||
PageSize: setting.UI.User.RepoPagingNum,
|
||||
Collaborate: util.OptionalBoolFalse,
|
||||
TopicOnly: topicOnly,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("SearchRepositoryByName", err)
|
||||
return
|
||||
}
|
||||
|
||||
total = int(count)
|
||||
}
|
||||
ctx.Data["Repos"] = repos
|
||||
ctx.Data["Total"] = total
|
||||
|
Reference in New Issue
Block a user