From a6821209d12ca1bea29b633d0fbd1f818acca24b Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sun, 20 Oct 2019 21:52:25 -0400 Subject: [PATCH] Fixed weighted random cap not working. Nothing would return if there were more than 4 sponsors. --- index.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index eef91cb..8210489 100644 --- a/index.js +++ b/index.js @@ -740,11 +740,9 @@ function getVoteOrganisedSponsorTimes(sponsorTimes, votes, UUIDs) { let voteSums = weightedRandomIndexes.weightSums; //convert these into the votes - for (let i = 0; i < voteSums.length; i++) { - if (voteSums[i] != undefined) { - //it should use the sum of votes, since anyone upvoting a similar sponsor is upvoting the existence of that sponsor. - votes[finalSponsorTimeIndexes[i]] = voteSums; - } + for (let i = 0; i < finalSponsorTimeIndexes.length; i++) { + //it should use the sum of votes, since anyone upvoting a similar sponsor is upvoting the existence of that sponsor. + votes[finalSponsorTimeIndexes[i]] = voteSums[i]; } //find the indexes never dealt with and add them