summaryrefslogtreecommitdiffstats
path: root/models/issue_label.go
diff options
context:
space:
mode:
authorAndrey Nering <andrey.nering@gmail.com>2016-11-10 21:18:34 -0200
committerGitHub <noreply@github.com>2016-11-10 21:18:34 -0200
commit52cc3fd36a60add3780b9684f811fe2caf602c31 (patch)
tree125d7c43e3a1070c19c754b97fe2847192399e5e /models/issue_label.go
parent4247304f5aeb791e3e201947478eef4964744146 (diff)
parentb12f2a5916e74d89244a51847b753d1f9c585976 (diff)
downloadgitea-52cc3fd36a60add3780b9684f811fe2caf602c31.tar.gz
gitea-52cc3fd36a60add3780b9684f811fe2caf602c31.zip
Merge pull request #136 from 0xbaadf00d/feature/rewrite-xorm-queries
Rewrite raw 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 65ef077bf0..83773fda6e 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.