summaryrefslogtreecommitdiffstats
path: root/models/issue_label.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-02-11 20:01:33 +0800
committerKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-02-12 06:46:51 +0100
commitd76f34ef519f773ab66f2ba9f91c65a3aaf6537e (patch)
tree148008a128074bf6cecdd764a8130821a8080048 /models/issue_label.go
parent3f676760599896f168e454d132b368658751974a (diff)
downloadgitea-d76f34ef519f773ab66f2ba9f91c65a3aaf6537e.tar.gz
gitea-d76f34ef519f773ab66f2ba9f91c65a3aaf6537e.zip
small optimization for get issue labels
Diffstat (limited to 'models/issue_label.go')
-rw-r--r--models/issue_label.go21
1 files changed, 4 insertions, 17 deletions
diff --git a/models/issue_label.go b/models/issue_label.go
index 015e7f128d..67e0ac77b5 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -190,23 +190,10 @@ func GetLabelsByRepoID(repoID int64, sortType string) ([]*Label, error) {
}
func getLabelsByIssueID(e Engine, issueID int64) ([]*Label, error) {
- issueLabels, err := getIssueLabels(e, issueID)
- if err != nil {
- return nil, fmt.Errorf("getIssueLabels: %v", err)
- } else if len(issueLabels) == 0 {
- return []*Label{}, nil
- }
-
- labelIDs := make([]int64, len(issueLabels))
- for i := range issueLabels {
- labelIDs[i] = issueLabels[i].LabelID
- }
-
- labels := make([]*Label, 0, len(labelIDs))
- return labels, e.
- Where("id > 0").
- In("id", labelIDs).
- Asc("name").
+ var labels []*Label
+ return labels, e.Where("issue_label.issue_id = ?", issueID).
+ Join("LEFT", "issue_label", "issue_label.label_id = label.id").
+ Asc("label.name").
Find(&labels)
}