1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-16 07:18:37 +00:00

API endpoint for subscribers (#598)

This commit is contained in:
Ethan Koenig
2017-01-06 22:13:02 -05:00
committed by Lunny Xiao
parent 03b45284e1
commit 8422ab542c
3 changed files with 30 additions and 7 deletions

View File

@@ -2107,13 +2107,10 @@ func GetWatchers(repoID int64) ([]*Watch, error) {
// GetWatchers returns range of users watching given repository.
func (repo *Repository) GetWatchers(page int) ([]*User, error) {
users := make([]*User, 0, ItemsPerPage)
sess := x.
Limit(ItemsPerPage, (page-1)*ItemsPerPage).
Where("watch.repo_id=?", repo.ID)
if setting.UsePostgreSQL {
sess = sess.Join("LEFT", "watch", `"user".id=watch.user_id`)
} else {
sess = sess.Join("LEFT", "watch", "user.id=watch.user_id")
sess := x.Where("watch.repo_id=?", repo.ID).
Join("LEFT", "watch", "`user`.id=`watch`.user_id")
if page > 0 {
sess = sess.Limit(ItemsPerPage, (page-1)*ItemsPerPage)
}
return users, sess.Find(&users)
}