fix: wrong pages number which includes private repository count. (#844)

This commit is contained in:
Bo-Yi Wu 2017-02-06 23:18:36 +08:00 committed by Lunny Xiao
parent 76969a5671
commit 71d35dae8c
4 changed files with 105 additions and 4 deletions

View file

@ -134,14 +134,27 @@ func Profile(ctx *context.Context) {
keyword := ctx.Query("q")
if len(keyword) == 0 {
var total int
repos, err = models.GetUserRepositories(ctxUser.ID, showPrivate, page, setting.UI.User.RepoPagingNum, orderBy)
if err != nil {
ctx.Handle(500, "GetRepositories", err)
return
}
ctx.Data["Repos"] = repos
ctx.Data["Page"] = paginater.New(ctxUser.NumRepos, setting.UI.User.RepoPagingNum, page, 5)
ctx.Data["Total"] = ctxUser.NumRepos
if showPrivate {
total = ctxUser.NumRepos
} else {
count, err := models.GetPublicRepositoryCount(ctxUser)
if err != nil {
ctx.Handle(500, "GetPublicRepositoryCount", err)
return
}
total = int(count)
}
ctx.Data["Page"] = paginater.New(total, setting.UI.User.RepoPagingNum, page, 5)
ctx.Data["Total"] = total
} else {
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
Keyword: keyword,