mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-03 00:45:22 +02:00
more context for models (#19511)
make more usage of context, to have more db transaction in one session (make diff of #9307 smaller)
This commit is contained in:
parent
332b2ecd21
commit
06e4687cec
54 changed files with 275 additions and 245 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue