aboutsummaryrefslogtreecommitdiff
path: root/routers/user
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-12-27 22:01:18 +0800
committerUnknwon <u@gogs.io>2016-12-27 22:01:18 +0800
commit8059175a5c0363519ba28fb8fc5f9d494f6a209d (patch)
treef21775c9c1abbdad73b1d6d98984f5ac1780cba4 /routers/user
parentf8fd084bd2c7c2a4d642daad59dceaf40686269e (diff)
Fix dashboard issues/pull request counting
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/home.go31
-rw-r--r--routers/user/profile.go7
2 files changed, 32 insertions, 6 deletions
diff --git a/routers/user/home.go b/routers/user/home.go
index d1a58356..f413a223 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -218,6 +218,12 @@ func Issues(ctx *context.Context) {
userRepoIDs = make([]int64, 0, len(repos))
for _, repo := range repos {
+ userRepoIDs = append(userRepoIDs, repo.ID)
+
+ if filterMode != models.FILTER_MODE_YOUR_REPOS {
+ continue
+ }
+
if isPullList {
if isShowClosed && repo.NumClosedPulls == 0 ||
!isShowClosed && repo.NumOpenPulls == 0 {
@@ -231,9 +237,15 @@ func Issues(ctx *context.Context) {
}
}
- userRepoIDs = append(userRepoIDs, repo.ID)
- if filterMode == models.FILTER_MODE_YOUR_REPOS {
- showRepos = append(showRepos, repo)
+ showRepos = append(showRepos, repo)
+ }
+
+ // Filter repositories if the page shows issues.
+ if !isPullList {
+ userRepoIDs, err = models.FilterRepositoryWithIssues(userRepoIDs)
+ if err != nil {
+ ctx.Handle(500, "FilterRepositoryWithIssues", err)
+ return
}
}
@@ -247,7 +259,11 @@ func Issues(ctx *context.Context) {
switch filterMode {
case models.FILTER_MODE_YOUR_REPOS:
// Get all issues from repositories from this user.
- issueOptions.RepoIDs = userRepoIDs
+ if userRepoIDs == nil {
+ issueOptions.RepoIDs = []int64{-1}
+ } else {
+ issueOptions.RepoIDs = userRepoIDs
+ }
case models.FILTER_MODE_ASSIGN:
// Get all issues assigned to this user.
@@ -361,7 +377,12 @@ func showOrgProfile(ctx *context.Context) {
ctx.Data["Repos"] = repos
} else {
showPrivate := ctx.IsSigned && ctx.User.IsAdmin
- repos, err = models.GetUserRepositories(org.ID, showPrivate, page, setting.UI.User.RepoPagingNum)
+ repos, err = models.GetUserRepositories(&models.UserRepoOptions{
+ UserID: org.ID,
+ Private: showPrivate,
+ Page: page,
+ PageSize: setting.UI.User.RepoPagingNum,
+ })
if err != nil {
ctx.Handle(500, "GetRepositories", err)
return
diff --git a/routers/user/profile.go b/routers/user/profile.go
index 363705dd..3558e8b0 100644
--- a/routers/user/profile.go
+++ b/routers/user/profile.go
@@ -99,7 +99,12 @@ func Profile(ctx *context.Context) {
page = 1
}
- ctx.Data["Repos"], err = models.GetUserRepositories(ctxUser.ID, ctx.IsSigned && ctx.User.ID == ctxUser.ID, page, setting.UI.User.RepoPagingNum)
+ ctx.Data["Repos"], err = models.GetUserRepositories(&models.UserRepoOptions{
+ UserID: ctxUser.ID,
+ Private: ctx.IsSigned && ctx.User.ID == ctxUser.ID,
+ Page: page,
+ PageSize: setting.UI.User.RepoPagingNum,
+ })
if err != nil {
ctx.Handle(500, "GetRepositories", err)
return