Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify and fix GetApprovalCounts #11086

Merged
merged 2 commits into from
Apr 16, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
FIX by simplify
  • Loading branch information
6543 committed Apr 16, 2020
commit 7738cf47f6174c7a4f2ea40c0685f17333663fc0
15 changes: 4 additions & 11 deletions models/issue_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,17 +535,10 @@ func (issues IssueList) getApprovalCounts(e Engine) (map[int64][]*ReviewCount, e
}

approvalCountMap := make(map[int64][]*ReviewCount, len(issues))
if len(rCounts) > 0 {
start := 0
lastID := rCounts[0].IssueID
for i, current := range rCounts[1:] {
if lastID != current.IssueID {
approvalCountMap[lastID] = rCounts[start:i]
start = i
lastID = current.IssueID
}
}
approvalCountMap[lastID] = rCounts[start:]

for _, c := range rCounts {
approvalCountMap[c.IssueID] = append(approvalCountMap[c.IssueID], c)
}

return approvalCountMap, nil
}