aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-03-30 13:30:39 +0800
committerGitHub <noreply@github.com>2020-03-30 02:30:39 -0300
commitf490291bea98308c55e61e68245becda42270b4c (patch)
treeb279e2ffb10955d49b9d4835790a90a0f4d7ec6f /models/issue.go
parent5c3be56f7bad9f068b8e8c0c3d6664b6847349c6 (diff)
downloadgitea-f490291bea98308c55e61e68245becda42270b4c.tar.gz
gitea-f490291bea98308c55e61e68245becda42270b4c.zip
Use subquery to instead In (#10874)
* Use subquery to instead In * Support excludedLabelNames on issues options * Fix tests Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/issue.go')
-rw-r--r--models/issue.go30
1 files changed, 20 insertions, 10 deletions
diff --git a/models/issue.go b/models/issue.go
index 03af32700d..8aa02873a1 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -1045,16 +1045,18 @@ func GetIssuesByIDs(issueIDs []int64) ([]*Issue, error) {
// IssuesOptions represents options of an issue.
type IssuesOptions struct {
ListOptions
- RepoIDs []int64 // include all repos if empty
- AssigneeID int64
- PosterID int64
- MentionedID int64
- MilestoneID int64
- IsClosed util.OptionalBool
- IsPull util.OptionalBool
- LabelIDs []int64
- SortType string
- IssueIDs []int64
+ RepoIDs []int64 // include all repos if empty
+ AssigneeID int64
+ PosterID int64
+ MentionedID int64
+ MilestoneID int64
+ IsClosed util.OptionalBool
+ IsPull util.OptionalBool
+ LabelIDs []int64
+ IncludedLabelNames []string
+ ExcludedLabelNames []string
+ SortType string
+ IssueIDs []int64
// prioritize issues from this repo
PriorityRepoID int64
}
@@ -1153,6 +1155,14 @@ func (opts *IssuesOptions) setupSession(sess *xorm.Session) {
}
}
}
+
+ if len(opts.IncludedLabelNames) > 0 {
+ sess.In("issue.id", BuildLabelNamesIssueIDsCondition(opts.IncludedLabelNames))
+ }
+
+ if len(opts.ExcludedLabelNames) > 0 {
+ sess.And(builder.NotIn("issue.id", BuildLabelNamesIssueIDsCondition(opts.ExcludedLabelNames)))
+ }
}
// CountIssuesByRepo map from repoID to number of issues matching the options