Previously, the code was selecting randomly among all categories with
at least a quorum of votes. With this commit, the code now does what
was intended, by selecting randomly only among the categories that are
tied for the most votes.
if (max_votes < quorum)
return null;
if (max_votes < quorum)
return null;
- const candidates = props.prompts.filter(p => p.votes.length >= quorum);
+ const candidates = props.prompts.filter(p => p.votes.length >= max_votes);
const index = Math.floor(Math.random() * candidates.length);
const winner = candidates[index];
const index = Math.floor(Math.random() * candidates.length);
const winner = candidates[index];