From 9e1079ac2c9d017520c55d50da4c037d03a24081 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Sun, 23 Apr 2023 16:12:23 +0800 Subject: [PATCH 1/3] fix: load reviewer when dismisses a review --- models/issues/issue.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/models/issues/issue.go b/models/issues/issue.go index 4f8e9e161d29..48aeeb99adab 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -378,6 +378,16 @@ func (issue *Issue) LoadAttributes(ctx context.Context) (err error) { if err = CommentList(issue.Comments).loadAttributes(ctx); err != nil { return err } + for _, comment := range issue.Comments { + // If the comment dismisses a review, we need to load the reviewer to show whose review has been dismissed. + // Otherwise, the reviewer is the poster of the comment, so we don't need to load it. + if comment.Type == CommentTypeDismissReview { + if err := comment.Review.LoadReviewer(ctx); err != nil { + return err + } + } + } + if issue.IsTimetrackerEnabled(ctx) { if err = issue.LoadTotalTimes(ctx); err != nil { return err From 69c073f56f2a91c0bda19bc71129f8654073413f Mon Sep 17 00:00:00 2001 From: Jason Song Date: Sun, 23 Apr 2023 17:10:12 +0800 Subject: [PATCH 2/3] fix: move --- models/issues/comment_list.go | 8 ++++++++ models/issues/issue.go | 10 ---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/models/issues/comment_list.go b/models/issues/comment_list.go index 0411d44531ee..fd499ec230d1 100644 --- a/models/issues/comment_list.go +++ b/models/issues/comment_list.go @@ -453,6 +453,14 @@ func (comments CommentList) loadReviews(ctx context.Context) error { //nolint for _, comment := range comments { comment.Review = reviews[comment.ReviewID] + + // If the comment dismisses a review, we need to load the reviewer to show whose review has been dismissed. + // Otherwise, the reviewer is the poster of the comment, so we don't need to load it. + if comment.Type == CommentTypeDismissReview { + if err := comment.Review.LoadReviewer(ctx); err != nil { + return err + } + } } return nil } diff --git a/models/issues/issue.go b/models/issues/issue.go index 48aeeb99adab..4f8e9e161d29 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -378,16 +378,6 @@ func (issue *Issue) LoadAttributes(ctx context.Context) (err error) { if err = CommentList(issue.Comments).loadAttributes(ctx); err != nil { return err } - for _, comment := range issue.Comments { - // If the comment dismisses a review, we need to load the reviewer to show whose review has been dismissed. - // Otherwise, the reviewer is the poster of the comment, so we don't need to load it. - if comment.Type == CommentTypeDismissReview { - if err := comment.Review.LoadReviewer(ctx); err != nil { - return err - } - } - } - if issue.IsTimetrackerEnabled(ctx) { if err = issue.LoadTotalTimes(ctx); err != nil { return err From fe34c4538a4f7c20c8d7ddd5ed569656e4164675 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Sun, 23 Apr 2023 17:28:47 +0800 Subject: [PATCH 3/3] chore: remove unused nolint --- models/issues/comment_list.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/issues/comment_list.go b/models/issues/comment_list.go index fd499ec230d1..477337443ddf 100644 --- a/models/issues/comment_list.go +++ b/models/issues/comment_list.go @@ -56,7 +56,7 @@ func (comments CommentList) getLabelIDs() []int64 { return ids.Values() } -func (comments CommentList) loadLabels(ctx context.Context) error { //nolint +func (comments CommentList) loadLabels(ctx context.Context) error { if len(comments) == 0 { return nil } @@ -415,7 +415,7 @@ func (comments CommentList) getReviewIDs() []int64 { return ids.Values() } -func (comments CommentList) loadReviews(ctx context.Context) error { //nolint +func (comments CommentList) loadReviews(ctx context.Context) error { if len(comments) == 0 { return nil }