aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue.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/issue.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/issue.go')
-rw-r--r--models/issue.go20
1 files changed, 8 insertions, 12 deletions
diff --git a/models/issue.go b/models/issue.go
index 8bb46bde7e..2a41cbc28e 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -162,13 +162,9 @@ func (issue *Issue) GetPullRequest() (pr *PullRequest, err error) {
}
// LoadLabels loads labels
-func (issue *Issue) LoadLabels() error {
- return issue.loadLabels(db.GetEngine(db.DefaultContext))
-}
-
-func (issue *Issue) loadLabels(e db.Engine) (err error) {
+func (issue *Issue) LoadLabels(ctx context.Context) (err error) {
if issue.Labels == nil {
- issue.Labels, err = getLabelsByIssueID(e, issue.ID)
+ issue.Labels, err = getLabelsByIssueID(db.GetEngine(ctx), issue.ID)
if err != nil {
return fmt.Errorf("getLabelsByIssueID [%d]: %v", issue.ID, err)
}
@@ -313,7 +309,7 @@ func (issue *Issue) loadAttributes(ctx context.Context) (err error) {
return
}
- if err = issue.loadLabels(e); err != nil {
+ if err = issue.LoadLabels(ctx); err != nil {
return
}
@@ -493,7 +489,7 @@ func ClearIssueLabels(issue *Issue, doer *user_model.User) (err error) {
return err
}
- perm, err := getUserRepoPermission(ctx, issue.Repo, doer)
+ perm, err := GetUserRepoPermission(ctx, issue.Repo, doer)
if err != nil {
return err
}
@@ -539,7 +535,7 @@ func ReplaceIssueLabels(issue *Issue, labels []*Label, doer *user_model.User) (e
return err
}
- if err = issue.loadLabels(db.GetEngine(ctx)); err != nil {
+ if err = issue.LoadLabels(ctx); err != nil {
return err
}
@@ -587,7 +583,7 @@ func ReplaceIssueLabels(issue *Issue, labels []*Label, doer *user_model.User) (e
}
issue.Labels = nil
- if err = issue.loadLabels(db.GetEngine(ctx)); err != nil {
+ if err = issue.LoadLabels(ctx); err != nil {
return err
}
@@ -2341,9 +2337,9 @@ func ResolveIssueMentionsByVisibility(ctx context.Context, issue *Issue, doer *u
continue
}
// Normal users must have read access to the referencing issue
- perm, err := getUserRepoPermission(ctx, issue.Repo, user)
+ perm, err := GetUserRepoPermission(ctx, issue.Repo, user)
if err != nil {
- return nil, fmt.Errorf("getUserRepoPermission [%d]: %v", user.ID, err)
+ return nil, fmt.Errorf("GetUserRepoPermission [%d]: %v", user.ID, err)
}
if !perm.CanReadIssuesOrPulls(issue.IsPull) {
continue