summaryrefslogtreecommitdiffstats
path: root/models/issues/review.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/issues/review.go')
-rw-r--r--models/issues/review.go25
1 files changed, 23 insertions, 2 deletions
diff --git a/models/issues/review.go b/models/issues/review.go
index ed30bce149..06cf132a48 100644
--- a/models/issues/review.go
+++ b/models/issues/review.go
@@ -162,6 +162,27 @@ func (r *Review) LoadReviewer(ctx context.Context) (err error) {
return err
}
+// LoadReviewers loads reviewers
+func LoadReviewers(ctx context.Context, reviews []*Review) (err error) {
+ reviewerIds := make([]int64, len(reviews))
+ for i := 0; i < len(reviews); i++ {
+ reviewerIds[i] = reviews[i].ReviewerID
+ }
+ reviewers, err := user_model.GetPossibleUserByIDs(ctx, reviewerIds)
+ if err != nil {
+ return err
+ }
+
+ userMap := make(map[int64]*user_model.User, len(reviewers))
+ for _, reviewer := range reviewers {
+ userMap[reviewer.ID] = reviewer
+ }
+ for _, review := range reviews {
+ review.Reviewer = userMap[review.ReviewerID]
+ }
+ return nil
+}
+
// LoadReviewerTeam loads reviewer team
func (r *Review) LoadReviewerTeam(ctx context.Context) (err error) {
if r.ReviewerTeamID == 0 || r.ReviewerTeam != nil {
@@ -520,8 +541,8 @@ func GetReviews(ctx context.Context, opts *GetReviewOptions) ([]*Review, error)
return reviews, sess.Find(&reviews)
}
-// GetReviewersByIssueID gets the latest review of each reviewer for a pull request
-func GetReviewersByIssueID(issueID int64) ([]*Review, error) {
+// GetReviewsByIssueID gets the latest review of each reviewer for a pull request
+func GetReviewsByIssueID(issueID int64) ([]*Review, error) {
reviews := make([]*Review, 0, 10)
sess := db.GetEngine(db.DefaultContext)