summaryrefslogtreecommitdiffstats
path: root/models/issue.go
diff options
context:
space:
mode:
authorjaqra <48099350+jaqra@users.noreply.github.com>2019-11-05 09:48:51 +0300
committertechknowlogick <techknowlogick@gitea.io>2019-11-05 01:48:51 -0500
commitc0f4675a68278ce648cdefe73b7b6b65327ed89a (patch)
tree277a339e6eb1e1bd34e159868fe1ed7d6750af12 /models/issue.go
parenta91679c9e337c46ab3e441097236f7a4dc07938d (diff)
downloadgitea-c0f4675a68278ce648cdefe73b7b6b65327ed89a.tar.gz
gitea-c0f4675a68278ce648cdefe73b7b6b65327ed89a.zip
Fix (open/closed) issue count when label excluded (#8815)
* Fix (open/closed) issue count when label excluded * Use capital sql keywords
Diffstat (limited to 'models/issue.go')
-rw-r--r--models/issue.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/models/issue.go b/models/issue.go
index 78413468b2..1e9d973186 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -1293,8 +1293,12 @@ func GetIssueStats(opts *IssueStatsOptions) (*IssueStats, error) {
log.Warn("Malformed Labels argument: %s", opts.Labels)
} else {
for i, labelID := range labelIDs {
- sess.Join("INNER", fmt.Sprintf("issue_label il%d", i),
- fmt.Sprintf("issue.id = il%[1]d.issue_id AND il%[1]d.label_id = %[2]d", i, labelID))
+ if labelID > 0 {
+ sess.Join("INNER", fmt.Sprintf("issue_label il%d", i),
+ fmt.Sprintf("issue.id = il%[1]d.issue_id AND il%[1]d.label_id = %[2]d", i, labelID))
+ } else {
+ sess.Where("issue.id NOT IN (SELECT issue_id FROM issue_label WHERE label_id = ?)", -labelID)
+ }
}
}
}