]> source.dussan.org Git - gitea.git/commitdiff
Fix (open/closed) issue count when label excluded (#8815)
authorjaqra <48099350+jaqra@users.noreply.github.com>
Tue, 5 Nov 2019 06:48:51 +0000 (09:48 +0300)
committertechknowlogick <techknowlogick@gitea.io>
Tue, 5 Nov 2019 06:48:51 +0000 (01:48 -0500)
* Fix (open/closed) issue count when label excluded

* Use capital sql keywords

models/issue.go

index 78413468b20320aee1fba87b9e407c702fb1bf7a..1e9d9731861fe138a4f13a933a357fe076ef1faf 100644 (file)
@@ -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)
+                                       }
                                }
                        }
                }