summaryrefslogtreecommitdiffstats
path: root/models/repo_watch.go
diff options
context:
space:
mode:
authorguillep2k <18600385+guillep2k@users.noreply.github.com>2019-11-18 05:08:20 -0300
committerzeripath <art27@cantab.net>2019-11-18 08:08:20 +0000
commit08ae6bb7edb9582c38edb8a0dba1b1be10fb00fc (patch)
treec64e9a1c9cfaeb6cd0c2ee012d3ad32c38e78ce3 /models/repo_watch.go
parent9ff63126274b0df6e035541eafd48970c402e61e (diff)
downloadgitea-08ae6bb7edb9582c38edb8a0dba1b1be10fb00fc.tar.gz
gitea-08ae6bb7edb9582c38edb8a0dba1b1be10fb00fc.zip
Rewrite delivery of issue and comment mails (#9009)
* Mail issue subscribers, rework the function * Simplify a little more * Fix unused variable * Refactor mail delivery to avoid heavy load on server * Avoid splitting into too many goroutines * Fix comments and optimize GetMaileableUsersByIDs() * Fix return on errors
Diffstat (limited to 'models/repo_watch.go')
-rw-r--r--models/repo_watch.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/models/repo_watch.go b/models/repo_watch.go
index 2de4f8b320..2279dcb115 100644
--- a/models/repo_watch.go
+++ b/models/repo_watch.go
@@ -140,6 +140,18 @@ func GetWatchers(repoID int64) ([]*Watch, error) {
return getWatchers(x, repoID)
}
+// GetRepoWatchersIDs returns IDs of watchers for a given repo ID
+// but avoids joining with `user` for performance reasons
+// User permissions must be verified elsewhere if required
+func GetRepoWatchersIDs(repoID int64) ([]int64, error) {
+ ids := make([]int64, 0, 64)
+ return ids, x.Table("watch").
+ Where("watch.repo_id=?", repoID).
+ And("watch.mode<>?", RepoWatchModeDont).
+ Select("user_id").
+ Find(&ids)
+}
+
// GetWatchers returns range of users watching given repository.
func (repo *Repository) GetWatchers(page int) ([]*User, error) {
users := make([]*User, 0, ItemsPerPage)