diff options
author | Unknown <joe2010xtmf@163.com> | 2014-03-19 23:39:00 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-03-19 23:39:00 -0400 |
commit | 59ea3c0413723521e7504fa5b1be2c3780cbb2ea (patch) | |
tree | 2c8ee0aa410e590f7ecadeec7f46ddedd4191a24 /models/repo.go | |
parent | a922c3ff6a65d6d0550f36d866a301a6737ca8a2 (diff) |
Finish watch backend
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/models/repo.go b/models/repo.go index 187862fe..fa6d9702 100644 --- a/models/repo.go +++ b/models/repo.go @@ -50,6 +50,7 @@ type Watch struct { UserId int64 `xorm:"UNIQUE(watch)"` } +// Watch or unwatch repository. func WatchRepo(userId, repoId int64, watch bool) (err error) { if watch { _, err = orm.Insert(&Watch{RepoId: repoId, UserId: userId}) @@ -59,6 +60,13 @@ func WatchRepo(userId, repoId int64, watch bool) (err error) { return err } +// GetWatches returns all watches of given repository. +func GetWatches(repoId int64) ([]Watch, error) { + watches := make([]Watch, 0, 10) + err := orm.Find(&watches, &Watch{RepoId: repoId}) + return watches, err +} + var ( gitInitLocker = sync.Mutex{} LanguageIgns, Licenses []string |