diff options
author | Ethan Koenig <ethantkoenig@gmail.com> | 2017-12-25 18:25:16 -0500 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-12-26 01:25:16 +0200 |
commit | 4c9341f689e840df30db3e227498a30fdb5b88ef (patch) | |
tree | 6a619eee5cee0bc9e988019e0abd521acc57c184 /routers | |
parent | fabf3f2fc29e143dabefd504cda78d3f47807d2c (diff) | |
download | gitea-4c9341f689e840df30db3e227498a30fdb5b88ef.tar.gz gitea-4c9341f689e840df30db3e227498a30fdb5b88ef.zip |
Fix bugs in issue dashboard stats (#3073)
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/issue.go | 2 | ||||
-rw-r--r-- | routers/repo/issue.go | 2 | ||||
-rw-r--r-- | routers/user/home.go | 33 |
3 files changed, 29 insertions, 8 deletions
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 08815ee074..c2d4819f05 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -56,7 +56,7 @@ func ListIssues(ctx *context.APIContext) { } issues, err := models.Issues(&models.IssuesOptions{ - RepoID: ctx.Repo.Repository.ID, + RepoIDs: []int64{ctx.Repo.Repository.ID}, Page: ctx.QueryInt("page"), PageSize: setting.UI.IssuePagingNum, IsClosed: isClosed, diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 4e12d62f30..530586a143 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -190,8 +190,8 @@ func Issues(ctx *context.Context) { issues = []*models.Issue{} } else { issues, err = models.Issues(&models.IssuesOptions{ + RepoIDs: []int64{repo.ID}, AssigneeID: assigneeID, - RepoID: repo.ID, PosterID: posterID, MentionedID: mentionedID, MilestoneID: milestoneID, 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 { |