(e Engine, userID, repoID int64, watch bool)
| 2363 | } |
| 2364 | |
| 2365 | func watchRepo(e Engine, userID, repoID int64, watch bool) (err error) { |
| 2366 | if watch { |
| 2367 | if isWatching(e, userID, repoID) { |
| 2368 | return nil |
| 2369 | } |
| 2370 | if _, err = e.Insert(&Watch{RepoID: repoID, UserID: userID}); err != nil { |
| 2371 | return err |
| 2372 | } |
| 2373 | _, err = e.Exec("UPDATE `repository` SET num_watches = num_watches + 1 WHERE id = ?", repoID) |
| 2374 | } else { |
| 2375 | if !isWatching(e, userID, repoID) { |
| 2376 | return nil |
| 2377 | } |
| 2378 | if _, err = e.Delete(&Watch{0, userID, repoID}); err != nil { |
| 2379 | return err |
| 2380 | } |
| 2381 | _, err = e.Exec("UPDATE `repository` SET num_watches = num_watches - 1 WHERE id = ?", repoID) |
| 2382 | } |
| 2383 | return err |
| 2384 | } |
| 2385 | |
| 2386 | // Watch or unwatch repository. |
| 2387 | // |
no test coverage detected