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:
6543 2022-04-28 13:48:48 +02:00 committed by GitHub
parent 332b2ecd21
commit 06e4687cec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 275 additions and 245 deletions

View file

@ -238,7 +238,7 @@ func isOfficialReviewer(ctx context.Context, issue *Issue, reviewers ...*user_mo
if err != nil {
return false, err
}
if err = pr.loadProtectedBranch(ctx); err != nil {
if err = pr.LoadProtectedBranchCtx(ctx); err != nil {
return false, err
}
if pr.ProtectedBranch == nil {
@ -265,7 +265,7 @@ func isOfficialReviewerTeam(ctx context.Context, issue *Issue, team *organizatio
if err != nil {
return false, err
}
if err = pr.loadProtectedBranch(ctx); err != nil {
if err = pr.LoadProtectedBranchCtx(ctx); err != nil {
return false, err
}
if pr.ProtectedBranch == nil {
@ -891,7 +891,7 @@ func CanMarkConversation(issue *Issue, doer *user_model.User) (permResult bool,
return false, err
}
p, err := GetUserRepoPermission(issue.Repo, doer)
p, err := GetUserRepoPermission(db.DefaultContext, issue.Repo, doer)
if err != nil {
return false, err
}