summaryrefslogtreecommitdiffstats
path: root/models/user.go
diff options
context:
space:
mode:
authorEthan Koenig <ethantkoenig@gmail.com>2016-11-14 17:33:58 -0500
committerEthan Koenig <ethantkoenig@gmail.com>2016-11-16 22:51:54 -0500
commit0834e492c06e30d30c2bc8eec4fcb6c499a62ced (patch)
tree9a7888958b31770b2a4a4411e08095452f1d5e4a /models/user.go
parent871c964ef7aaf70af5e9eab00a3d6642432b122a (diff)
downloadgitea-0834e492c06e30d30c2bc8eec4fcb6c499a62ced.tar.gz
gitea-0834e492c06e30d30c2bc8eec4fcb6c499a62ced.zip
API endpoints for stars
Diffstat (limited to 'models/user.go')
-rw-r--r--models/user.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/models/user.go b/models/user.go
index 0b6063fbc9..e8c5c91680 100644
--- a/models/user.go
+++ b/models/user.go
@@ -1179,3 +1179,18 @@ func UnfollowUser(userID, followID int64) (err error) {
}
return sess.Commit()
}
+
+// GetStarredRepos returns the repos starred by a particular user
+func GetStarredRepos(userID int64, private bool) ([]*Repository, error) {
+ sess := x.Where("star.uid=?", userID).
+ Join("LEFT", "star", "`repository`.id=`star`.repo_id")
+ if !private {
+ sess = sess.And("is_private=?", false)
+ }
+ repos := make([]*Repository, 0, 10)
+ err := sess.Find(&repos)
+ if err != nil {
+ return nil, err
+ }
+ return repos, nil
+}