aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
author赵智超 <1012112796@qq.com>2020-10-14 20:11:11 +0800
committerGitHub <noreply@github.com>2020-10-14 13:11:11 +0100
commit97980146c52c1cb27e18f60fcd876519d53dad2f (patch)
treeb691cbcabd95e16f5b3d994164611df2b21d1f75 /models
parente70df67d4792826b51f0d2186816bf7651d1653d (diff)
downloadgitea-97980146c52c1cb27e18f60fcd876519d53dad2f.tar.gz
gitea-97980146c52c1cb27e18f60fcd876519d53dad2f.zip
Show original author's reviews on pull summary box (#13127)
follow #12039, show original author's reviews by other way. fix #11705. Signed-off-by: a1012112796 <1012112796@qq.com>
Diffstat (limited to 'models')
-rw-r--r--models/review.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/models/review.go b/models/review.go
index 2c38176ef4..326b06b5ed 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)