瀏覽代碼

Bug fix

tags/v0.9.99
Unknown 10 年之前
父節點
當前提交
53a17bbd24
共有 1 個文件被更改,包括 11 次插入2 次删除
  1. 11
    2
      models/repo.go

+ 11
- 2
models/repo.go 查看文件

@@ -424,9 +424,18 @@ type Watch struct {
// Watch or unwatch repository.
func WatchRepo(userId, repoId int64, watch bool) (err error) {
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 {
_, 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
}

Loading…
取消
儲存