@@ -201,12 +201,12 @@ func (issue *Issue) IsTimetrackerEnabled(ctx context.Context) bool {
201
201
}
202
202
203
203
// GetPullRequest returns the issue pull request
204
- func (issue * Issue ) GetPullRequest () (pr * PullRequest , err error ) {
204
+ func (issue * Issue ) GetPullRequest (ctx context. Context ) (pr * PullRequest , err error ) {
205
205
if ! issue .IsPull {
206
206
return nil , fmt .Errorf ("Issue is not a pull request" )
207
207
}
208
208
209
- pr , err = GetPullRequestByIssueID (db . DefaultContext , issue .ID )
209
+ pr , err = GetPullRequestByIssueID (ctx , issue .ID )
210
210
if err != nil {
211
211
return nil , err
212
212
}
@@ -369,9 +369,9 @@ func (issue *Issue) LoadAttributes(ctx context.Context) (err error) {
369
369
}
370
370
371
371
// GetIsRead load the `IsRead` field of the issue
372
- func (issue * Issue ) GetIsRead (userID int64 ) error {
372
+ func (issue * Issue ) GetIsRead (ctx context. Context , userID int64 ) error {
373
373
issueUser := & IssueUser {IssueID : issue .ID , UID : userID }
374
- if has , err := db .GetEngine (db . DefaultContext ).Get (issueUser ); err != nil {
374
+ if has , err := db .GetEngine (ctx ).Get (issueUser ); err != nil {
375
375
return err
376
376
} else if ! has {
377
377
issue .IsRead = false
@@ -382,9 +382,9 @@ func (issue *Issue) GetIsRead(userID int64) error {
382
382
}
383
383
384
384
// APIURL returns the absolute APIURL to this issue.
385
- func (issue * Issue ) APIURL () string {
385
+ func (issue * Issue ) APIURL (ctx context. Context ) string {
386
386
if issue .Repo == nil {
387
- err := issue .LoadRepo (db . DefaultContext )
387
+ err := issue .LoadRepo (ctx )
388
388
if err != nil {
389
389
log .Error ("Issue[%d].APIURL(): %v" , issue .ID , err )
390
390
return ""
@@ -479,9 +479,9 @@ func (issue *Issue) GetLastEventLabel() string {
479
479
}
480
480
481
481
// GetLastComment return last comment for the current issue.
482
- func (issue * Issue ) GetLastComment () (* Comment , error ) {
482
+ func (issue * Issue ) GetLastComment (ctx context. Context ) (* Comment , error ) {
483
483
var c Comment
484
- exist , err := db .GetEngine (db . DefaultContext ).Where ("type = ?" , CommentTypeComment ).
484
+ exist , err := db .GetEngine (ctx ).Where ("type = ?" , CommentTypeComment ).
485
485
And ("issue_id = ?" , issue .ID ).Desc ("created_unix" ).Get (& c )
486
486
if err != nil {
487
487
return nil , err
@@ -543,12 +543,12 @@ func GetIssueByID(ctx context.Context, id int64) (*Issue, error) {
543
543
}
544
544
545
545
// GetIssueWithAttrsByID returns an issue with attributes by given ID.
546
- func GetIssueWithAttrsByID (id int64 ) (* Issue , error ) {
547
- issue , err := GetIssueByID (db . DefaultContext , id )
546
+ func GetIssueWithAttrsByID (ctx context. Context , id int64 ) (* Issue , error ) {
547
+ issue , err := GetIssueByID (ctx , id )
548
548
if err != nil {
549
549
return nil , err
550
550
}
551
- return issue , issue .LoadAttributes (db . DefaultContext )
551
+ return issue , issue .LoadAttributes (ctx )
552
552
}
553
553
554
554
// GetIssuesByIDs return issues with the given IDs.
@@ -600,8 +600,8 @@ func GetParticipantsIDsByIssueID(ctx context.Context, issueID int64) ([]int64, e
600
600
}
601
601
602
602
// IsUserParticipantsOfIssue return true if user is participants of an issue
603
- func IsUserParticipantsOfIssue (user * user_model.User , issue * Issue ) bool {
604
- userIDs , err := issue .GetParticipantIDsByIssue (db . DefaultContext )
603
+ func IsUserParticipantsOfIssue (ctx context. Context , user * user_model.User , issue * Issue ) bool {
604
+ userIDs , err := issue .GetParticipantIDsByIssue (ctx )
605
605
if err != nil {
606
606
log .Error (err .Error ())
607
607
return false
@@ -894,8 +894,8 @@ func IsErrIssueMaxPinReached(err error) bool {
894
894
}
895
895
896
896
// InsertIssues insert issues to database
897
- func InsertIssues (issues ... * Issue ) error {
898
- ctx , committer , err := db .TxContext (db . DefaultContext )
897
+ func InsertIssues (ctx context. Context , issues ... * Issue ) error {
898
+ ctx , committer , err := db .TxContext (ctx )
899
899
if err != nil {
900
900
return err
901
901
}
0 commit comments