summaryrefslogtreecommitdiffstats
path: root/models/issue.go
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2021-11-08 22:14:46 +0100
committerGitHub <noreply@github.com>2021-11-08 23:14:46 +0200
commita3f9e9234cbb099b821a6ea9c575927be18948de (patch)
tree24740136097ba5f4dfc39723bc6479d2c8dc5b54 /models/issue.go
parent640f0e1ddf7a5cae8a778e989046e7438067a56c (diff)
downloadgitea-a3f9e9234cbb099b821a6ea9c575927be18948de.tar.gz
gitea-a3f9e9234cbb099b821a6ea9c575927be18948de.zip
Fix stats upon searching issues (#17566)
* Fix stat chunks searching - Fixes a issue whereby the given chunk of issueIDs wasn't respected and thus the returned results where not the correct results. * Add tests Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/issue.go')
-rw-r--r--models/issue.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/models/issue.go b/models/issue.go
index 0bc1ebd209..75aafe51b7 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -1527,12 +1527,12 @@ func GetIssueStats(opts *IssueStatsOptions) (*IssueStats, error) {
func getIssueStatsChunk(opts *IssueStatsOptions, issueIDs []int64) (*IssueStats, error) {
stats := &IssueStats{}
- countSession := func(opts *IssueStatsOptions) *xorm.Session {
+ countSession := func(opts *IssueStatsOptions, issueIDs []int64) *xorm.Session {
sess := db.GetEngine(db.DefaultContext).
Where("issue.repo_id = ?", opts.RepoID)
- if len(opts.IssueIDs) > 0 {
- sess.In("issue.id", opts.IssueIDs)
+ if len(issueIDs) > 0 {
+ sess.In("issue.id", issueIDs)
}
if len(opts.Labels) > 0 && opts.Labels != "0" {
@@ -1582,13 +1582,13 @@ func getIssueStatsChunk(opts *IssueStatsOptions, issueIDs []int64) (*IssueStats,
}
var err error
- stats.OpenCount, err = countSession(opts).
+ stats.OpenCount, err = countSession(opts, issueIDs).
And("issue.is_closed = ?", false).
Count(new(Issue))
if err != nil {
return stats, err
}
- stats.ClosedCount, err = countSession(opts).
+ stats.ClosedCount, err = countSession(opts, issueIDs).
And("issue.is_closed = ?", true).
Count(new(Issue))
return stats, err