diff --git a/models/review.go b/models/review.go index 2c38176ef..326b06b5e 100644 --- a/models/review.go +++ b/models/review.go @@ -486,6 +486,20 @@ func GetReviewersByIssueID(issueID int64) ([]*Review, error) { return reviews, nil } +// GetReviewersFromOriginalAuthorsByIssueID gets the latest review of each original authors for a pull request +func GetReviewersFromOriginalAuthorsByIssueID(issueID int64) ([]*Review, error) { + reviews := make([]*Review, 0, 10) + + // Get latest review of each reviwer, sorted in order they were made + if err := x.SQL("SELECT * FROM review WHERE id IN (SELECT max(id) as id FROM review WHERE issue_id = ? AND reviewer_team_id = 0 AND type in (?, ?, ?) AND original_author_id <> 0 GROUP BY issue_id, original_author_id) ORDER BY review.updated_unix ASC", + issueID, ReviewTypeApprove, ReviewTypeReject, ReviewTypeRequest). + Find(&reviews); err != nil { + return nil, err + } + + return reviews, nil +} + // GetReviewByIssueIDAndUserID get the latest review of reviewer for a pull request func GetReviewByIssueIDAndUserID(issueID, userID int64) (*Review, error) { return getReviewByIssueIDAndUserID(x, issueID, userID) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 797764709..8aef32209 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -450,6 +450,13 @@ type repoReviewerSelection struct { func RetrieveRepoReviewers(ctx *context.Context, repo *models.Repository, issue *models.Issue, canChooseReviewer bool) { ctx.Data["CanChooseReviewer"] = canChooseReviewer + originalAuthorReviews, err := models.GetReviewersFromOriginalAuthorsByIssueID(issue.ID) + if err != nil { + ctx.ServerError("GetReviewersFromOriginalAuthorsByIssueID", err) + return + } + ctx.Data["OriginalReviews"] = originalAuthorReviews + reviews, err := models.GetReviewersByIssueID(issue.ID) if err != nil { ctx.ServerError("GetReviewersByIssueID", err) diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl index d043c269e..a67783ebb 100644 --- a/templates/repo/issue/view_content/pull.tmpl +++ b/templates/repo/issue/view_content/pull.tmpl @@ -1,4 +1,4 @@ -{{if .PullReviewers }} +{{if or .PullReviewers .OriginalReviews }}