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
This commit is contained in:
parent
d81e31ad78
commit
fd7d83ace6
232 changed files with 1463 additions and 2108 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue