summaryrefslogtreecommitdiffstats
path: root/models/issue_label.go
diff options
context:
space:
mode:
authorThibault Meyer <meyer.thibault@gmail.com>2016-11-10 16:16:32 +0100
committerThibault Meyer <meyer.thibault@gmail.com>2016-11-10 20:59:51 +0100
commita4454f5d0fbeaacb94668012acbb4296465cb28f (patch)
treeeaf39d1935eda44cf16df08234d2bbddd39c3ddd /models/issue_label.go
parentc040f2fbb13ef5ba2c6a619322d4801e9f78c885 (diff)
downloadgitea-a4454f5d0fbeaacb94668012acbb4296465cb28f.tar.gz
gitea-a4454f5d0fbeaacb94668012acbb4296465cb28f.zip
Rewrite XORM queries
Diffstat (limited to 'models/issue_label.go')
-rw-r--r--models/issue_label.go26
1 files changed, 21 insertions, 5 deletions
diff --git a/models/issue_label.go b/models/issue_label.go
index 24d6bcac75..b77abee49f 100644
--- a/models/issue_label.go
+++ b/models/issue_label.go
@@ -138,13 +138,20 @@ func GetLabelInRepoByID(repoID, labelID int64) (*Label, error) {
// it silently ignores label IDs that are not belong to the repository.
func GetLabelsInRepoByIDs(repoID int64, labelIDs []int64) ([]*Label, error) {
labels := make([]*Label, 0, len(labelIDs))
- return labels, x.Where("repo_id = ?", repoID).In("id", base.Int64sToStrings(labelIDs)).Asc("name").Find(&labels)
+ return labels, x.
+ Where("repo_id = ?", repoID).
+ In("id", base.Int64sToStrings(labelIDs)).
+ Asc("name").
+ Find(&labels)
}
// GetLabelsByRepoID returns all labels that belong to given repository by ID.
func GetLabelsByRepoID(repoID int64) ([]*Label, error) {
labels := make([]*Label, 0, 10)
- return labels, x.Where("repo_id = ?", repoID).Asc("name").Find(&labels)
+ return labels, x.
+ Where("repo_id = ?", repoID).
+ Asc("name").
+ Find(&labels)
}
func getLabelsByIssueID(e Engine, issueID int64) ([]*Label, error) {
@@ -161,7 +168,11 @@ func getLabelsByIssueID(e Engine, issueID int64) ([]*Label, error) {
}
labels := make([]*Label, 0, len(labelIDs))
- return labels, e.Where("id > 0").In("id", base.Int64sToStrings(labelIDs)).Asc("name").Find(&labels)
+ return labels, e.
+ Where("id > 0").
+ In("id", base.Int64sToStrings(labelIDs)).
+ Asc("name").
+ Find(&labels)
}
// GetLabelsByIssueID returns all labels that belong to given issue by ID.
@@ -197,7 +208,9 @@ func DeleteLabel(repoID, labelID int64) error {
if _, err = sess.Id(labelID).Delete(new(Label)); err != nil {
return err
- } else if _, err = sess.Where("label_id = ?", labelID).Delete(new(IssueLabel)); err != nil {
+ } else if _, err = sess.
+ Where("label_id = ?", labelID).
+ Delete(new(IssueLabel)); err != nil {
return err
}
@@ -293,7 +306,10 @@ func NewIssueLabels(issue *Issue, labels []*Label) (err error) {
func getIssueLabels(e Engine, issueID int64) ([]*IssueLabel, error) {
issueLabels := make([]*IssueLabel, 0, 10)
- return issueLabels, e.Where("issue_id=?", issueID).Asc("label_id").Find(&issueLabels)
+ return issueLabels, e.
+ Where("issue_id=?", issueID).
+ Asc("label_id").
+ Find(&issueLabels)
}
// GetIssueLabels returns all issue-label relations of given issue by ID.