summaryrefslogtreecommitdiffstats
path: root/models/review.go
diff options
context:
space:
mode:
authorJonas Franz <info@jonasfranz.software>2018-12-11 12:28:37 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2018-12-11 19:28:37 +0800
commit9681c8373426e8364760f033b9935b81b9276351 (patch)
treed9308c33809fdfa7859fd9a1057432a74a28c92f /models/review.go
parent64680b72bd1b0a0fc164296ff0cc7319ae7dc4ca (diff)
downloadgitea-9681c8373426e8364760f033b9935b81b9276351.tar.gz
gitea-9681c8373426e8364760f033b9935b81b9276351.zip
Approvals at Branch Protection (#5350)
* Add branch protection for approvals Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add required approvals Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing comments and fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add type = approval and group by reviewer_id to review * Prevent users from adding negative review limits * Add migration for approval whitelists Signed-off-by: Jonas Franz <info@jonasfranz.software>
Diffstat (limited to 'models/review.go')
-rw-r--r--models/review.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/models/review.go b/models/review.go
index 3ae1dd457c..91b6d6dbb2 100644
--- a/models/review.go
+++ b/models/review.go
@@ -161,6 +161,23 @@ func GetReviewByID(id int64) (*Review, error) {
return getReviewByID(x, id)
}
+func getUniqueApprovalsByPullRequestID(e Engine, prID int64) (reviews []*Review, err error) {
+ reviews = make([]*Review, 0)
+ if err := e.
+ Where("issue_id = ? AND type = ?", prID, ReviewTypeApprove).
+ OrderBy("updated_unix").
+ GroupBy("reviewer_id").
+ Find(&reviews); err != nil {
+ return nil, err
+ }
+ return
+}
+
+// GetUniqueApprovalsByPullRequestID returns all reviews submitted for a specific pull request
+func GetUniqueApprovalsByPullRequestID(prID int64) ([]*Review, error) {
+ return getUniqueApprovalsByPullRequestID(x, prID)
+}
+
// FindReviewOptions represent possible filters to find reviews
type FindReviewOptions struct {
Type ReviewType