Fix close issue but time watcher still running (#17643)

* Fix close issue but time watcher still running

* refactor stopwatch codes

* Fix test

* Fix test

* Fix typo

* Fix test
This commit is contained in:
Lunny Xiao 2021-11-21 17:11:48 +08:00 committed by GitHub
parent ab09296d37
commit 0add627182
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 159 additions and 118 deletions

View file

@ -9,6 +9,7 @@ import (
"net/http"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/routers/api/v1/utils"
@ -55,7 +56,7 @@ func StartIssueStopwatch(ctx *context.APIContext) {
return
}
if err := models.CreateOrStopIssueStopwatch(ctx.User, issue); err != nil {
if err := models.CreateIssueStopwatch(db.DefaultContext, ctx.User, issue); err != nil {
ctx.Error(http.StatusInternalServerError, "CreateOrStopIssueStopwatch", err)
return
}
@ -104,7 +105,7 @@ func StopIssueStopwatch(ctx *context.APIContext) {
return
}
if err := models.CreateOrStopIssueStopwatch(ctx.User, issue); err != nil {
if err := models.FinishIssueStopwatch(db.DefaultContext, ctx.User, issue); err != nil {
ctx.Error(http.StatusInternalServerError, "CreateOrStopIssueStopwatch", err)
return
}