Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont load Review if Comment is CommentTypeReviewRequest #28551

Merged
merged 17 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions models/issues/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,15 @@ func (c *Comment) LoadReactions(ctx context.Context, repo *repo_model.Repository
}

func (c *Comment) loadReview(ctx context.Context) (err error) {
if c.ReviewID == 0 {
return nil
}
if c.Review == nil {
if c.Review, err = GetReviewByID(ctx, c.ReviewID); err != nil {
// review request which has been replaced by actual reviews doesn't exist in database anymore, so ignorem them.
if c.Type == CommentTypeReviewRequest {
return nil
}
return err
}
}
Expand Down
9 changes: 8 additions & 1 deletion models/issues/comment_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,16 @@ func (comments CommentList) loadReviews(ctx context.Context) error {
}

for _, comment := range comments {
// skip review request as the comment struct already has all the info needed to display the infos.
// also it would throw errors for all review requests who has been replaced by actual reviews
// as they do not exist in database anymore.
if comment.Type == CommentTypeReviewRequest {
6543 marked this conversation as resolved.
Show resolved Hide resolved
continue
}
6543 marked this conversation as resolved.
Show resolved Hide resolved
comment.Review = reviews[comment.ReviewID]
if comment.Review == nil {
if comment.ReviewID > 0 {
// review request which has been replaced by actual reviews doesn't exist in database anymore, so don't log errors for them.
if comment.ReviewID > 0 && comment.Type != CommentTypeReviewRequest {
log.Error("comment with review id [%d] but has no review record", comment.ReviewID)
}
continue
Expand Down
3 changes: 3 additions & 0 deletions models/issues/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ func AddReviewRequest(ctx context.Context, issue *Issue, reviewer, doer *user_mo
return nil, err
}

// func caller use the created comment to retrieve created review too.
comment.Review = review

return comment, committer.Commit()
}

Expand Down
Loading