aboutsummaryrefslogtreecommitdiffstats
path: root/routers/user/profile.go
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2017-02-06 23:18:36 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-06 23:18:36 +0800
commit71d35dae8cd33760b9be266a38d4f76b00ceb373 (patch)
treecf801d761f147e0fd73d56ca9e6956f5e3f116e1 /routers/user/profile.go
parent76969a5671987d0aba5bfb72a7989aae71692254 (diff)
downloadgitea-71d35dae8cd33760b9be266a38d4f76b00ceb373.tar.gz
gitea-71d35dae8cd33760b9be266a38d4f76b00ceb373.zip
fix: wrong pages number which includes private repository count. (#844)
Diffstat (limited to 'routers/user/profile.go')
-rw-r--r--routers/user/profile.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/routers/user/profile.go b/routers/user/profile.go
index 3b4d5a6b3c..ef6cb9cd9d 100644
--- a/routers/user/profile.go
+++ b/routers/user/profile.go
@@ -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,