Skip to content

Commit

Permalink
Add proposal billing list max page size
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlyp committed Jul 23, 2020
1 parent 8c0f859 commit 115e746
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions politeiawww/api/cms/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ const (
// statement contained within a DCC
PolicyMaxSponsorStatementLength = 5000

// ProposalBillingListPageSize is the maximum number of proposal billing
// summaries returned for the routes that return lists of proposal billing
// summaries.
ProposalBillingListPageSize = 50

ErrorStatusMalformedName www.ErrorStatusT = 1001
ErrorStatusMalformedLocation www.ErrorStatusT = 1002
ErrorStatusInvoiceNotFound www.ErrorStatusT = 1003
Expand Down
9 changes: 8 additions & 1 deletion politeiawww/invoices.go
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,12 @@ func (p *politeiawww) processProposalBillingSummary(pbs cms.ProposalBillingSumma
}

approvedProposals := tvr.Approved

count := pbs.Count
if count > cms.ProposalBillingListPageSize {
count = cms.ProposalBillingListPageSize
}

proposalInvoices := make(map[string][]*database.Invoice, len(approvedProposals))
for i, prop := range approvedProposals {
if i < pbs.Offset {
Expand All @@ -1817,10 +1823,11 @@ func (p *politeiawww) processProposalBillingSummary(pbs cms.ProposalBillingSumma
proposalInvoices[prop] = make([]*database.Invoice, 0)
}

if pbs.Count != 0 && len(proposalInvoices) >= pbs.Count {
if count != 0 && len(proposalInvoices) >= count {
break
}
}

spendingSummaries := make([]cms.ProposalSpending, 0, len(proposalInvoices))
for prop, invoices := range proposalInvoices {
spendingSummary := cms.ProposalSpending{}
Expand Down

0 comments on commit 115e746

Please sign in to comment.