fix(Polls): Calculate vote percentage based on total number of votes

Percentage was previously calculated based on number of voters
This commit is contained in:
Vlad Piersec 2021-12-13 11:00:59 +02:00 committed by vp8x8
parent f20a50d8a6
commit 69cbb7e103
1 changed files with 2 additions and 2 deletions

View File

@ -72,10 +72,10 @@ const AbstractPollResults = (Component: AbstractComponent<AbstractProps>) => (pr
}
}
const totalVoters = voterSet.size;
const totalVotes = pollDetails.answers.reduce((sum, { voters: { size } }) => sum + size, 0);
return pollDetails.answers.map(answer => {
const percentage = totalVoters === 0 ? 0 : Math.round(answer.voters.size / totalVoters * 100);
const percentage = totalVotes === 0 ? 0 : Math.round(answer.voters.size / totalVotes * 100);
let voters = null;