|
|
@ -742,18 +742,10 @@ func RemoveReviewRequest(issue *Issue, reviewer, doer *user_model.User) (*Commen |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} else if official { |
|
|
|
} else if official { |
|
|
|
// recalculate the latest official review for reviewer
|
|
|
|
if err := restoreLatestOfficialReview(ctx, issue.ID, reviewer.ID); err != nil { |
|
|
|
review, err := GetReviewByIssueIDAndUserID(ctx, issue.ID, reviewer.ID) |
|
|
|
|
|
|
|
if err != nil && !IsErrReviewNotExist(err) { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if review != nil { |
|
|
|
|
|
|
|
if _, err := db.Exec(ctx, "UPDATE `review` SET official=? WHERE id=?", true, review.ID); err != nil { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
comment, err := CreateCommentCtx(ctx, &CreateCommentOptions{ |
|
|
|
comment, err := CreateCommentCtx(ctx, &CreateCommentOptions{ |
|
|
|
Type: CommentTypeReviewRequest, |
|
|
|
Type: CommentTypeReviewRequest, |
|
|
@ -770,6 +762,22 @@ func RemoveReviewRequest(issue *Issue, reviewer, doer *user_model.User) (*Commen |
|
|
|
return comment, committer.Commit() |
|
|
|
return comment, committer.Commit() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Recalculate the latest official review for reviewer
|
|
|
|
|
|
|
|
func restoreLatestOfficialReview(ctx context.Context, issueID, reviewerID int64) error { |
|
|
|
|
|
|
|
review, err := GetReviewByIssueIDAndUserID(ctx, issueID, reviewerID) |
|
|
|
|
|
|
|
if err != nil && !IsErrReviewNotExist(err) { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if review != nil { |
|
|
|
|
|
|
|
if _, err := db.Exec(ctx, "UPDATE `review` SET official=? WHERE id=?", true, review.ID); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// AddTeamReviewRequest add a review request from one team
|
|
|
|
// AddTeamReviewRequest add a review request from one team
|
|
|
|
func AddTeamReviewRequest(issue *Issue, reviewer *organization.Team, doer *user_model.User) (*Comment, error) { |
|
|
|
func AddTeamReviewRequest(issue *Issue, reviewer *organization.Team, doer *user_model.User) (*Comment, error) { |
|
|
|
ctx, committer, err := db.TxContext() |
|
|
|
ctx, committer, err := db.TxContext() |
|
|
@ -988,6 +996,12 @@ func DeleteReview(r *Review) error { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if r.Official { |
|
|
|
|
|
|
|
if err := restoreLatestOfficialReview(ctx, r.IssueID, r.ReviewerID); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return committer.Commit() |
|
|
|
return committer.Commit() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|