summaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2017-12-25 18:25:16 -0500
committerLauris BH <lauris@nix.lv>2017-12-26 01:25:16 +0200
commit4c9341f689e840df30db3e227498a30fdb5b88ef (patch)
tree6a619eee5cee0bc9e988019e0abd521acc57c184 /routers/user
parentfabf3f2fc29e143dabefd504cda78d3f47807d2c (diff)
downloadgitea-4c9341f689e840df30db3e227498a30fdb5b88ef.tar.gz
gitea-4c9341f689e840df30db3e227498a30fdb5b88ef.zip
Fix bugs in issue dashboard stats (#3073)
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/home.go33
1 files changed, 27 insertions, 6 deletions
diff --git a/routers/user/home.go b/routers/user/home.go
index 756da4f57f..01a1068134 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -9,13 +9,14 @@ import (
"fmt"
"sort"
- "github.com/Unknwon/paginater"
-
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
+
+ "github.com/Unknwon/com"
+ "github.com/Unknwon/paginater"
)
const (
@@ -231,21 +232,30 @@ func Issues(ctx *context.Context) {
return
}
}
-
if len(userRepoIDs) <= 0 {
userRepoIDs = []int64{-1}
}
opts := &models.IssuesOptions{
- RepoID: repoID,
IsClosed: util.OptionalBoolOf(isShowClosed),
IsPull: util.OptionalBoolOf(isPullList),
SortType: sortType,
}
+ if repoID > 0 {
+ opts.RepoIDs = []int64{repoID}
+ }
+
switch filterMode {
case models.FilterModeAll:
- opts.RepoIDs = userRepoIDs
+ if repoID > 0 {
+ if !com.IsSliceContainsInt64(userRepoIDs, repoID) {
+ // force an empty result
+ opts.RepoIDs = []int64{-1}
+ }
+ } else {
+ opts.RepoIDs = userRepoIDs
+ }
case models.FilterModeAssign:
opts.AssigneeID = ctxUser.ID
case models.FilterModeCreate:
@@ -308,7 +318,18 @@ func Issues(ctx *context.Context) {
issue.Repo = showReposMap[issue.RepoID]
}
- issueStats := models.GetUserIssueStats(repoID, ctxUser.ID, userRepoIDs, filterMode, isPullList)
+ issueStats, err := models.GetUserIssueStats(models.UserIssueStatsOptions{
+ UserID: ctxUser.ID,
+ RepoID: repoID,
+ UserRepoIDs: userRepoIDs,
+ FilterMode: filterMode,
+ IsPull: isPullList,
+ IsClosed: isShowClosed,
+ })
+ if err != nil {
+ ctx.Handle(500, "GetUserIssueStats", err)
+ return
+ }
var total int
if !isShowClosed {