diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-12-10 09:27:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 09:27:50 +0800 |
commit | 719bddcd76610a63dadc8555760072957a11cf30 (patch) | |
tree | 0df26092fba7e3e21444fe493e6b349473b6b0cb /models/issue_comment_list.go | |
parent | fb8166c6c6b652a0e6fa98681780a6a71090faf3 (diff) | |
download | gitea-719bddcd76610a63dadc8555760072957a11cf30.tar.gz gitea-719bddcd76610a63dadc8555760072957a11cf30.zip |
Move repository model into models/repo (#17933)
* Some refactors related repository model
* Move more methods out of repository
* Move repository into models/repo
* Fix test
* Fix test
* some improvements
* Remove unnecessary function
Diffstat (limited to 'models/issue_comment_list.go')
-rw-r--r-- | models/issue_comment_list.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/models/issue_comment_list.go b/models/issue_comment_list.go index ef6aff9cbe..23a2756dcf 100644 --- a/models/issue_comment_list.go +++ b/models/issue_comment_list.go @@ -5,6 +5,8 @@ package models import ( + "context" + "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" @@ -343,11 +345,12 @@ func (comments CommentList) getDependentIssueIDs() []int64 { return keysInt64(ids) } -func (comments CommentList) loadDependentIssues(e db.Engine) error { +func (comments CommentList) loadDependentIssues(ctx context.Context) error { if len(comments) == 0 { return nil } + e := db.GetEngine(ctx) issueIDs := comments.getDependentIssueIDs() issues := make(map[int64]*Issue, len(issueIDs)) left := len(issueIDs) @@ -383,7 +386,7 @@ func (comments CommentList) loadDependentIssues(e db.Engine) error { if comment.DependentIssue == nil { comment.DependentIssue = issues[comment.DependentIssueID] if comment.DependentIssue != nil { - if err := comment.DependentIssue.loadRepo(e); err != nil { + if err := comment.DependentIssue.loadRepo(ctx); err != nil { return err } } @@ -487,7 +490,8 @@ func (comments CommentList) loadReviews(e db.Engine) error { } // loadAttributes loads all attributes -func (comments CommentList) loadAttributes(e db.Engine) (err error) { +func (comments CommentList) loadAttributes(ctx context.Context) (err error) { + e := db.GetEngine(ctx) if err = comments.loadPosters(e); err != nil { return } @@ -520,7 +524,7 @@ func (comments CommentList) loadAttributes(e db.Engine) (err error) { return } - if err = comments.loadDependentIssues(e); err != nil { + if err = comments.loadDependentIssues(ctx); err != nil { return } @@ -530,7 +534,7 @@ func (comments CommentList) loadAttributes(e db.Engine) (err error) { // LoadAttributes loads attributes of the comments, except for attachments and // comments func (comments CommentList) LoadAttributes() error { - return comments.loadAttributes(db.GetEngine(db.DefaultContext)) + return comments.loadAttributes(db.DefaultContext) } // LoadAttachments loads attachments |