aboutsummaryrefslogtreecommitdiffstats
path: root/routers/user/home.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/user/home.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/user/home.go')
-rw-r--r--routers/user/home.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/routers/user/home.go b/routers/user/home.go
index 762fcca156..e310b97ad6 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -528,6 +528,12 @@ func Issues(ctx *context.Context) {
issues = []*models.Issue{}
}
+ approvalCounts, err := models.IssueList(issues).GetApprovalCounts()
+ if err != nil {
+ ctx.ServerError("ApprovalCounts", err)
+ return
+ }
+
showReposMap := make(map[int64]*models.Repository, len(counts))
for repoID := range counts {
if repoID > 0 {
@@ -639,6 +645,22 @@ func Issues(ctx *context.Context) {
}
ctx.Data["Issues"] = issues
+ 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["CommitStatus"] = commitStatus
ctx.Data["Repos"] = showRepos
ctx.Data["Counts"] = counts