Skip to content

Commit

Permalink
only batch proposals once
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlyp committed Jul 23, 2020
1 parent c9a3920 commit 81b8263
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions politeiawww/invoices.go
Original file line number Diff line number Diff line change
Expand Up @@ -1803,6 +1803,24 @@ func (p *politeiawww) processProposalBillingSummary(pbs cms.ProposalBillingSumma

approvedProposals := tvr.Approved

var bpr www.BatchProposalsReply
if len(approvedProposals) > 0 {
// Go fetch proposal information to get name/title.
bp := &www.BatchProposals{
Tokens: approvedProposals,
}

data, err := p.makeProposalsRequest(http.MethodPost, www.RouteBatchProposals, bp)
if err != nil {
return nil, err
}

err = json.Unmarshal(data, &bpr)
if err != nil {
return nil, err
}
}

count := pbs.Count
if count > cms.ProposalBillingListPageSize {
count = cms.ProposalBillingListPageSize
Expand Down Expand Up @@ -1841,22 +1859,13 @@ func (p *politeiawww) processProposalBillingSummary(pbs cms.ProposalBillingSumma
}
totalSpent += int64(payout.Total)
}
// Go fetch proposal information to get name/title.
bp := &www.BatchProposals{
Tokens: []string{prop},
}

data, err := p.makeProposalsRequest(http.MethodPost, www.RouteBatchProposals, bp)
if err != nil {
return nil, err
}

var bpr www.BatchProposalsReply
err = json.Unmarshal(data, &bpr)
if err != nil {
return nil, err
// Look across approved proposals batch reply for proposal name.
for _, propDetails := range bpr.Proposals {
if propDetails.CensorshipRecord.Token == prop {
spendingSummary.Title = propDetails.Name
break
}
}
spendingSummary.Title = bpr.Proposals[0].Name
spendingSummary.TotalBilled = totalSpent
spendingSummaries = append(spendingSummaries, spendingSummary)
}
Expand Down

0 comments on commit 81b8263

Please sign in to comment.