diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-03-30 13:30:39 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-30 02:30:39 -0300 |
commit | f490291bea98308c55e61e68245becda42270b4c (patch) | |
tree | b279e2ffb10955d49b9d4835790a90a0f4d7ec6f /models/issue_label.go | |
parent | 5c3be56f7bad9f068b8e8c0c3d6664b6847349c6 (diff) | |
download | gitea-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_label.go')
-rw-r--r-- | models/issue_label.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/models/issue_label.go b/models/issue_label.go index c111afb2ff..3b516a7aed 100644 --- a/models/issue_label.go +++ b/models/issue_label.go @@ -269,6 +269,17 @@ func GetLabelIDsInRepoByNames(repoID int64, labelNames []string) ([]int64, error Find(&labelIDs) } +// BuildLabelNamesIssueIDsCondition returns a builder where get issue ids match label names +func BuildLabelNamesIssueIDsCondition(labelNames []string) *builder.Builder { + return builder.Select("issue_label.issue_id"). + From("issue_label"). + InnerJoin("label", "label.id = issue_label.label_id"). + Where( + builder.In("label.name", labelNames), + ). + GroupBy("issue_label.issue_id") +} + // GetLabelIDsInReposByNames returns a list of labelIDs by names in one of the given // repositories. // it silently ignores label names that do not belong to the repository. |