Use for a repo action one database transaction (#19576)

... more context

(part of #9307)
This commit is contained in:
6543 2022-05-03 21:46:28 +02:00 committed by GitHub
parent 730420b6b3
commit 92f139d091
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 270 additions and 260 deletions

View file

@ -249,7 +249,7 @@ func (comment *Comment) addCrossReferences(stdCtx context.Context, doer *user_mo
if comment.Type != CommentTypeCode && comment.Type != CommentTypeComment {
return nil
}
if err := comment.loadIssue(db.GetEngine(stdCtx)); err != nil {
if err := comment.LoadIssueCtx(stdCtx); err != nil {
return err
}
ctx := &crossReferencesContext{
@ -340,9 +340,9 @@ func (comment *Comment) RefIssueIdent() string {
// \/ \/ |__| \/ \/
// ResolveCrossReferences will return the list of references to close/reopen by this PR
func (pr *PullRequest) ResolveCrossReferences() ([]*Comment, error) {
func (pr *PullRequest) ResolveCrossReferences(ctx context.Context) ([]*Comment, error) {
unfiltered := make([]*Comment, 0, 5)
if err := db.GetEngine(db.DefaultContext).
if err := db.GetEngine(ctx).
Where("ref_repo_id = ? AND ref_issue_id = ?", pr.Issue.RepoID, pr.Issue.ID).
In("ref_action", []references.XRefAction{references.XRefActionCloses, references.XRefActionReopens}).
OrderBy("id").