mirror of
https://github.com/go-gitea/gitea
synced 2024-11-16 07:04:25 +00:00
Bug fix
This commit is contained in:
parent
06631ab91f
commit
53a17bbd24
@ -424,9 +424,18 @@ type Watch struct {
|
|||||||
// Watch or unwatch repository.
|
// Watch or unwatch repository.
|
||||||
func WatchRepo(userId, repoId int64, watch bool) (err error) {
|
func WatchRepo(userId, repoId int64, watch bool) (err error) {
|
||||||
if watch {
|
if watch {
|
||||||
_, err = orm.Insert(&Watch{RepoId: repoId, UserId: userId})
|
if _, err = orm.Insert(&Watch{RepoId: repoId, UserId: userId}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
rawSql := "UPDATE `repository` SET num_watches = num_watches + 1 WHERE id = ?"
|
||||||
|
_, err = orm.Exec(rawSql, repoId)
|
||||||
} else {
|
} else {
|
||||||
_, err = orm.Delete(&Watch{0, repoId, userId})
|
if _, err = orm.Delete(&Watch{0, repoId, userId}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rawSql := "UPDATE `repository` SET num_watches = num_watches - 1 WHERE id = ?"
|
||||||
|
_, err = orm.Exec(rawSql, repoId)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user