summaryrefslogtreecommitdiffstats
path: root/models/star.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-01-06 02:05:09 -0500
committerLunny Xiao <xiaolunwen@gmail.com>2017-01-06 15:05:09 +0800
commit1a7fc53c98f06f79955d217f91c8a5553e5a27b3 (patch)
tree76d684ec41ce8077b7bb396ec0d84b2034d332b9 /models/star.go
parent61306fa737f693c3b325d9a8da047ba0b939537e (diff)
downloadgitea-1a7fc53c98f06f79955d217f91c8a5553e5a27b3.tar.gz
gitea-1a7fc53c98f06f79955d217f91c8a5553e5a27b3.zip
API endpoint for stargazers (#597)
Diffstat (limited to 'models/star.go')
-rw-r--r--models/star.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/models/star.go b/models/star.go
index e2feb2c4b6..923bab57b5 100644
--- a/models/star.go
+++ b/models/star.go
@@ -63,12 +63,12 @@ func IsStaring(userID, repoID int64) bool {
// GetStargazers returns the users that starred the repo.
func (repo *Repository) GetStargazers(page int) ([]*User, error) {
users := make([]*User, 0, ItemsPerPage)
- err := x.
- Limit(ItemsPerPage, (page-1)*ItemsPerPage).
- Where("star.repo_id = ?", repo.ID).
- Join("LEFT", "star", "`user`.id = star.uid").
- Find(&users)
- return users, err
+ sess := x.Where("star.repo_id = ?", repo.ID).
+ Join("LEFT", "star", "`user`.id = star.uid")
+ if page > 0 {
+ sess = sess.Limit(ItemsPerPage, (page-1)*ItemsPerPage)
+ }
+ return users, sess.Find(&users)
}
// GetStarredRepos returns the repos the user starred.