diff options
author | Ethan Koenig <etk39@cornell.edu> | 2017-01-06 22:13:02 -0500 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-01-07 11:13:02 +0800 |
commit | 8422ab542c69592b4629188d4460ca560307465b (patch) | |
tree | aa0d36b3584c3579a7385d194dcbc79115dd6340 /models | |
parent | 03b45284e1845f81d996c7f1cb059e8a8eebfe29 (diff) | |
download | gitea-8422ab542c69592b4629188d4460ca560307465b.tar.gz gitea-8422ab542c69592b4629188d4460ca560307465b.zip |
API endpoint for subscribers (#598)
Diffstat (limited to 'models')
-rw-r--r-- | models/repo.go | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/models/repo.go b/models/repo.go index 5f1cef3029..5868b8b705 100644 --- a/models/repo.go +++ b/models/repo.go @@ -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) } |