Skip to content

Commit

Permalink
fix(Polls): Calculate vote percentage based on total number of votes
Browse files Browse the repository at this point in the history
Percentage was previously calculated based on number of voters
  • Loading branch information
vp8x8 committed Dec 13, 2021
1 parent f20a50d commit 69cbb7e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions react/features/polls/components/AbstractPollResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 69cbb7e

Please sign in to comment.