aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_comment_list.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-09-19 19:49:59 +0800
committerGitHub <noreply@github.com>2021-09-19 19:49:59 +0800
commita4bfef265d9e512830350635a0489c2cdcd6508f (patch)
tree1e3c2ec94276dfcb2f8ba73a2ac075ba39c4a34a /models/issue_comment_list.go
parent462306e263db5a809dbe2cdf62e99307aeff28de (diff)
downloadgitea-a4bfef265d9e512830350635a0489c2cdcd6508f.tar.gz
gitea-a4bfef265d9e512830350635a0489c2cdcd6508f.zip
Move db related basic functions to models/db (#17075)
* Move db related basic functions to models/db * Fix lint * Fix lint * Fix test * Fix lint * Fix lint * revert unnecessary change * Fix test * Fix wrong replace string * Use *Context * Correct committer spelling and fix wrong replaced words Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/issue_comment_list.go')
-rw-r--r--models/issue_comment_list.go30
1 files changed, 16 insertions, 14 deletions
diff --git a/models/issue_comment_list.go b/models/issue_comment_list.go
index df1b1ac55f..b80fa129e2 100644
--- a/models/issue_comment_list.go
+++ b/models/issue_comment_list.go
@@ -4,6 +4,8 @@
package models
+import "code.gitea.io/gitea/models/db"
+
// CommentList defines a list of comments
type CommentList []*Comment
@@ -17,7 +19,7 @@ func (comments CommentList) getPosterIDs() []int64 {
return keysInt64(posterIDs)
}
-func (comments CommentList) loadPosters(e Engine) error {
+func (comments CommentList) loadPosters(e db.Engine) error {
if len(comments) == 0 {
return nil
}
@@ -70,7 +72,7 @@ func (comments CommentList) getLabelIDs() []int64 {
return keysInt64(ids)
}
-func (comments CommentList) loadLabels(e Engine) error {
+func (comments CommentList) loadLabels(e db.Engine) error {
if len(comments) == 0 {
return nil
}
@@ -120,7 +122,7 @@ func (comments CommentList) getMilestoneIDs() []int64 {
return keysInt64(ids)
}
-func (comments CommentList) loadMilestones(e Engine) error {
+func (comments CommentList) loadMilestones(e db.Engine) error {
if len(comments) == 0 {
return nil
}
@@ -163,7 +165,7 @@ func (comments CommentList) getOldMilestoneIDs() []int64 {
return keysInt64(ids)
}
-func (comments CommentList) loadOldMilestones(e Engine) error {
+func (comments CommentList) loadOldMilestones(e db.Engine) error {
if len(comments) == 0 {
return nil
}
@@ -206,7 +208,7 @@ func (comments CommentList) getAssigneeIDs() []int64 {
return keysInt64(ids)
}
-func (comments CommentList) loadAssignees(e Engine) error {
+func (comments CommentList) loadAssignees(e db.Engine) error {
if len(comments) == 0 {
return nil
}
@@ -280,7 +282,7 @@ func (comments CommentList) Issues() IssueList {
return issueList
}
-func (comments CommentList) loadIssues(e Engine) error {
+func (comments CommentList) loadIssues(e db.Engine) error {
if len(comments) == 0 {
return nil
}
@@ -337,7 +339,7 @@ func (comments CommentList) getDependentIssueIDs() []int64 {
return keysInt64(ids)
}
-func (comments CommentList) loadDependentIssues(e Engine) error {
+func (comments CommentList) loadDependentIssues(e db.Engine) error {
if len(comments) == 0 {
return nil
}
@@ -386,7 +388,7 @@ func (comments CommentList) loadDependentIssues(e Engine) error {
return nil
}
-func (comments CommentList) loadAttachments(e Engine) (err error) {
+func (comments CommentList) loadAttachments(e db.Engine) (err error) {
if len(comments) == 0 {
return nil
}
@@ -438,7 +440,7 @@ func (comments CommentList) getReviewIDs() []int64 {
return keysInt64(ids)
}
-func (comments CommentList) loadReviews(e Engine) error {
+func (comments CommentList) loadReviews(e db.Engine) error {
if len(comments) == 0 {
return nil
}
@@ -481,7 +483,7 @@ func (comments CommentList) loadReviews(e Engine) error {
}
// loadAttributes loads all attributes
-func (comments CommentList) loadAttributes(e Engine) (err error) {
+func (comments CommentList) loadAttributes(e db.Engine) (err error) {
if err = comments.loadPosters(e); err != nil {
return
}
@@ -524,20 +526,20 @@ func (comments CommentList) loadAttributes(e Engine) (err error) {
// LoadAttributes loads attributes of the comments, except for attachments and
// comments
func (comments CommentList) LoadAttributes() error {
- return comments.loadAttributes(x)
+ return comments.loadAttributes(db.DefaultContext().Engine())
}
// LoadAttachments loads attachments
func (comments CommentList) LoadAttachments() error {
- return comments.loadAttachments(x)
+ return comments.loadAttachments(db.DefaultContext().Engine())
}
// LoadPosters loads posters
func (comments CommentList) LoadPosters() error {
- return comments.loadPosters(x)
+ return comments.loadPosters(db.DefaultContext().Engine())
}
// LoadIssues loads issues of comments
func (comments CommentList) LoadIssues() error {
- return comments.loadIssues(x)
+ return comments.loadIssues(db.DefaultContext().Engine())
}