aboutsummaryrefslogtreecommitdiffstats
path: root/models/action.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-05-20 22:08:52 +0800
committerGitHub <noreply@github.com>2022-05-20 22:08:52 +0800
commitfd7d83ace60258acf7139c4c787aa8af75b7ba8c (patch)
tree50038348ec10485f72344f3ac80324e04abc1283 /models/action.go
parentd81e31ad7826a81fc7139f329f250594610a274b (diff)
downloadgitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.tar.gz
gitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.zip
Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
Diffstat (limited to 'models/action.go')
-rw-r--r--models/action.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/models/action.go b/models/action.go
index 6b662b3107..29e2ea47bd 100644
--- a/models/action.go
+++ b/models/action.go
@@ -222,9 +222,8 @@ func (a *Action) getCommentLink(ctx context.Context) string {
if a == nil {
return "#"
}
- e := db.GetEngine(ctx)
if a.Comment == nil && a.CommentID != 0 {
- a.Comment, _ = getCommentByID(e, a.CommentID)
+ a.Comment, _ = GetCommentByID(ctx, a.CommentID)
}
if a.Comment != nil {
return a.Comment.HTMLURL()
@@ -239,7 +238,7 @@ func (a *Action) getCommentLink(ctx context.Context) string {
return "#"
}
- issue, err := getIssueByID(e, issueID)
+ issue, err := getIssueByID(ctx, issueID)
if err != nil {
return "#"
}
@@ -340,8 +339,7 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, error) {
return nil, err
}
- e := db.GetEngine(ctx)
- sess := e.Where(cond).
+ sess := db.GetEngine(ctx).Where(cond).
Select("`action`.*"). // this line will avoid select other joined table's columns
Join("INNER", "repository", "`repository`.id = `action`.repo_id")
@@ -354,7 +352,7 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, error) {
return nil, fmt.Errorf("Find: %v", err)
}
- if err := ActionList(actions).loadAttributes(e); err != nil {
+ if err := ActionList(actions).loadAttributes(ctx); err != nil {
return nil, fmt.Errorf("LoadAttributes: %v", err)
}
@@ -504,7 +502,7 @@ func notifyWatchers(ctx context.Context, actions ...*Action) error {
permIssue = make([]bool, len(watchers))
permPR = make([]bool, len(watchers))
for i, watcher := range watchers {
- user, err := user_model.GetUserByIDEngine(e, watcher.UserID)
+ user, err := user_model.GetUserByIDCtx(ctx, watcher.UserID)
if err != nil {
permCode[i] = false
permIssue[i] = false