@@ -201,12 +201,12 @@ func (issue *Issue) IsTimetrackerEnabled(ctx context.Context) bool {
201201}
202202
203203// 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 ) {
205205 if ! issue .IsPull {
206206 return nil , fmt .Errorf ("Issue is not a pull request" )
207207 }
208208
209- pr , err = GetPullRequestByIssueID (db . DefaultContext , issue .ID )
209+ pr , err = GetPullRequestByIssueID (ctx , issue .ID )
210210 if err != nil {
211211 return nil , err
212212 }
@@ -369,9 +369,9 @@ func (issue *Issue) LoadAttributes(ctx context.Context) (err error) {
369369}
370370
371371// 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 {
373373 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 {
375375 return err
376376 } else if ! has {
377377 issue .IsRead = false
@@ -382,9 +382,9 @@ func (issue *Issue) GetIsRead(userID int64) error {
382382}
383383
384384// APIURL returns the absolute APIURL to this issue.
385- func (issue * Issue ) APIURL () string {
385+ func (issue * Issue ) APIURL (ctx context. Context ) string {
386386 if issue .Repo == nil {
387- err := issue .LoadRepo (db . DefaultContext )
387+ err := issue .LoadRepo (ctx )
388388 if err != nil {
389389 log .Error ("Issue[%d].APIURL(): %v" , issue .ID , err )
390390 return ""
@@ -479,9 +479,9 @@ func (issue *Issue) GetLastEventLabel() string {
479479}
480480
481481// 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 ) {
483483 var c Comment
484- exist , err := db .GetEngine (db . DefaultContext ).Where ("type = ?" , CommentTypeComment ).
484+ exist , err := db .GetEngine (ctx ).Where ("type = ?" , CommentTypeComment ).
485485 And ("issue_id = ?" , issue .ID ).Desc ("created_unix" ).Get (& c )
486486 if err != nil {
487487 return nil , err
@@ -543,12 +543,12 @@ func GetIssueByID(ctx context.Context, id int64) (*Issue, error) {
543543}
544544
545545// 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 )
548548 if err != nil {
549549 return nil , err
550550 }
551- return issue , issue .LoadAttributes (db . DefaultContext )
551+ return issue , issue .LoadAttributes (ctx )
552552}
553553
554554// GetIssuesByIDs return issues with the given IDs.
@@ -600,8 +600,8 @@ func GetParticipantsIDsByIssueID(ctx context.Context, issueID int64) ([]int64, e
600600}
601601
602602// 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 )
605605 if err != nil {
606606 log .Error (err .Error ())
607607 return false
@@ -894,8 +894,8 @@ func IsErrIssueMaxPinReached(err error) bool {
894894}
895895
896896// 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 )
899899 if err != nil {
900900 return err
901901 }
0 commit comments