summaryrefslogtreecommitdiffstats
path: root/models/issue_label.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/issue_label.go')
-rw-r--r--models/issue_label.go20
1 files changed, 15 insertions, 5 deletions
diff --git a/models/issue_label.go b/models/issue_label.go
index 39805ba80d..f06f0f97c3 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -171,12 +171,22 @@ func GetLabelsInRepoByIDs(repoID int64, labelIDs []int64) ([]*Label, error) {
}
// GetLabelsByRepoID returns all labels that belong to given repository by ID.
-func GetLabelsByRepoID(repoID int64) ([]*Label, error) {
+func GetLabelsByRepoID(repoID int64, sortType string) ([]*Label, error) {
labels := make([]*Label, 0, 10)
- return labels, x.
- Where("repo_id = ?", repoID).
- Asc("name").
- Find(&labels)
+ sess := x.Where("repo_id = ?", repoID)
+
+ switch sortType {
+ case "reversealphabetically":
+ sess.Desc("name")
+ case "leastissues":
+ sess.Asc("num_issues")
+ case "mostissues":
+ sess.Desc("num_issues")
+ default:
+ sess.Asc("name")
+ }
+
+ return labels, sess.Find(&labels)
}
func getLabelsByIssueID(e Engine, issueID int64) ([]*Label, error) {