diff options
Diffstat (limited to 'models/issue.go')
-rw-r--r-- | models/issue.go | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/models/issue.go b/models/issue.go index baca512ab0..850346674b 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1210,7 +1210,7 @@ type IssuesOptions struct { PageSize int IsClosed util.OptionalBool IsPull util.OptionalBool - Labels string + LabelIDs []int64 SortType string IssueIDs []int64 } @@ -1289,15 +1289,10 @@ func (opts *IssuesOptions) setupSession(sess *xorm.Session) error { sess.And("issue.is_pull=?", false) } - if len(opts.Labels) > 0 && opts.Labels != "0" { - labelIDs, err := base.StringsToInt64s(strings.Split(opts.Labels, ",")) - if err != nil { - return err - } - if len(labelIDs) > 0 { - sess. - Join("INNER", "issue_label", "issue.id = issue_label.issue_id"). - In("issue_label.label_id", labelIDs) + if opts.LabelIDs != nil { + for i, labelID := range opts.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)) } } return nil @@ -1475,9 +1470,11 @@ func GetIssueStats(opts *IssueStatsOptions) (*IssueStats, error) { labelIDs, err := base.StringsToInt64s(strings.Split(opts.Labels, ",")) if err != nil { log.Warn("Malformed Labels argument: %s", opts.Labels) - } else if len(labelIDs) > 0 { - sess.Join("INNER", "issue_label", "issue.id = issue_label.issue_id"). - In("issue_label.label_id", labelIDs) + } 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)) + } } } |