summaryrefslogtreecommitdiffstats
path: root/routers/repo/issue.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-03-06 03:44:06 +0000
committerGitHub <noreply@github.com>2020-03-06 03:44:06 +0000
commit80db44267ccb688c596e8375523af5cd92864d87 (patch)
treeb10136ec813c23e18ab30085a0b6f0e014550702 /routers/repo/issue.go
parentf422a115f461472db6892da9142e930c67e63128 (diff)
downloadgitea-80db44267ccb688c596e8375523af5cd92864d87.tar.gz
gitea-80db44267ccb688c596e8375523af5cd92864d87.zip
Add Approval Counts to pulls list (#10238)
* Add Approval Counts to pulls list Add simple approvals counts to pulls lists * Remove non-official counts * Add PR features to milestone_issues.tmpl
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r--routers/repo/issue.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index a4cd184c15..a8406d3154 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -216,6 +216,12 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB
}
}
+ approvalCounts, err := models.IssueList(issues).GetApprovalCounts()
+ if err != nil {
+ ctx.ServerError("ApprovalCounts", err)
+ return
+ }
+
var commitStatus = make(map[int64]*models.CommitStatus, len(issues))
// Get posters.
@@ -263,6 +269,22 @@ func issues(ctx *context.Context, milestoneID int64, isPullOption util.OptionalB
assigneeID = 0 // Reset ID to prevent unexpected selection of assignee.
}
+ ctx.Data["ApprovalCounts"] = func(issueID int64, typ string) int64 {
+ counts, ok := approvalCounts[issueID]
+ if !ok || len(counts) == 0 {
+ return 0
+ }
+ reviewTyp := models.ReviewTypeApprove
+ if typ == "reject" {
+ reviewTyp = models.ReviewTypeReject
+ }
+ for _, count := range counts {
+ if count.Type == reviewTyp {
+ return count.Count
+ }
+ }
+ return 0
+ }
ctx.Data["IssueStats"] = issueStats
ctx.Data["SelLabelIDs"] = labelIDs
ctx.Data["SelectLabels"] = selectLabels