mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-01 04:12:10 +00:00
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
This commit is contained in:
parent
f422a115f4
commit
80db44267c
8 changed files with 154 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue