diff options
author | Unknwon <u@gogs.io> | 2016-08-24 16:05:56 -0700 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-08-24 16:05:56 -0700 |
commit | 0b273ac4d566837b668d9e521476cd94ac28b6d4 (patch) | |
tree | 034db5238583a8f73bc5c83c2e4f1ae724eea092 /models/webhook.go | |
parent | 84b56c3c53fb931f569f9d0b5e2bf3832aba6abe (diff) | |
download | gitea-0b273ac4d566837b668d9e521476cd94ac28b6d4.tar.gz gitea-0b273ac4d566837b668d9e521476cd94ac28b6d4.zip |
#3383 code cleanup
Diffstat (limited to 'models/webhook.go')
-rw-r--r-- | models/webhook.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/models/webhook.go b/models/webhook.go index ad4ac189bb..01a014223b 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -210,15 +210,18 @@ func GetWebhookByOrgID(orgID, id int64) (*Webhook, error) { } // GetActiveWebhooksByRepoID returns all active webhooks of repository. -func GetActiveWebhooksByRepoID(repoID int64) (ws []*Webhook, err error) { - err = x.Where("repo_id=?", repoID).And("is_active=?", true).Find(&ws) - return ws, err +func GetActiveWebhooksByRepoID(repoID int64) ([]*Webhook, error) { + webhooks := make([]*Webhook, 0, 5) + return webhooks, x.Find(&webhooks, &Webhook{ + RepoID: repoID, + IsActive: true, + }) } -// GetWebhooksByRepoID returns all webhooks of repository. -func GetWebhooksByRepoID(repoID int64) (ws []*Webhook, err error) { - err = x.Find(&ws, &Webhook{RepoID: repoID}) - return ws, err +// GetWebhooksByRepoID returns all webhooks of a repository. +func GetWebhooksByRepoID(repoID int64) ([]*Webhook, error) { + webhooks := make([]*Webhook, 0, 5) + return webhooks, x.Find(&webhooks, &Webhook{RepoID: repoID}) } // UpdateWebhook updates information of webhook. |