summaryrefslogtreecommitdiffstats
path: root/models/pull_list.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-04-28 13:48:48 +0200
committerGitHub <noreply@github.com>2022-04-28 13:48:48 +0200
commit06e4687cecaed41500b653e5b8685f48b8b18310 (patch)
treea98dd6d0139ba5d89c7e08d3c52930d66a77119b /models/pull_list.go
parent332b2ecd214a79b49f3798f4f27fe02b23a17bf8 (diff)
downloadgitea-06e4687cecaed41500b653e5b8685f48b8b18310.tar.gz
gitea-06e4687cecaed41500b653e5b8685f48b8b18310.zip
more context for models (#19511)
make more usage of context, to have more db transaction in one session (make diff of #9307 smaller)
Diffstat (limited to 'models/pull_list.go')
-rw-r--r--models/pull_list.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/models/pull_list.go b/models/pull_list.go
index 9d4d428928..055119a1e5 100644
--- a/models/pull_list.go
+++ b/models/pull_list.go
@@ -5,6 +5,7 @@
package models
import (
+ "context"
"fmt"
"code.gitea.io/gitea/models/db"
@@ -158,13 +159,14 @@ func (prs PullRequestList) LoadAttributes() error {
return prs.loadAttributes(db.GetEngine(db.DefaultContext))
}
-func (prs PullRequestList) invalidateCodeComments(e db.Engine, doer *user_model.User, repo *git.Repository, branch string) error {
+// InvalidateCodeComments will lookup the prs for code comments which got invalidated by change
+func (prs PullRequestList) InvalidateCodeComments(ctx context.Context, doer *user_model.User, repo *git.Repository, branch string) error {
if len(prs) == 0 {
return nil
}
issueIDs := prs.getIssueIDs()
var codeComments []*Comment
- if err := e.
+ if err := db.GetEngine(ctx).
Where("type = ? and invalidated = ?", CommentTypeCode, false).
In("issue_id", issueIDs).
Find(&codeComments); err != nil {
@@ -177,8 +179,3 @@ func (prs PullRequestList) invalidateCodeComments(e db.Engine, doer *user_model.
}
return nil
}
-
-// InvalidateCodeComments will lookup the prs for code comments which got invalidated by change
-func (prs PullRequestList) InvalidateCodeComments(doer *user_model.User, repo *git.Repository, branch string) error {
- return prs.invalidateCodeComments(db.GetEngine(db.DefaultContext), doer, repo, branch)
-}