0
0
Fork 0

Fix the winners endpoint resetting the quote votes before comparison

This commit is contained in:
Oliver-Akins 2021-09-23 17:40:08 -06:00
parent 19411a71e4
commit c339e96578

View file

@ -22,11 +22,6 @@ const route: ServerRoute = {
// Run through all of the quotes to find the most voted for ones // Run through all of the quotes to find the most voted for ones
for (var quote of data.quotes) { for (var quote of data.quotes) {
if (finalize) {
quote.win_streak++;
quote.votes = 0;
};
// New maximum, remove all previous winners // New maximum, remove all previous winners
if (quote.votes > highest) { if (quote.votes > highest) {
winners = [ quote ]; winners = [ quote ];
@ -36,6 +31,12 @@ const route: ServerRoute = {
else if (quote.votes === highest) { else if (quote.votes === highest) {
winners.push( quote ); winners.push( quote );
}; };
// Reset the bracket data as needed
if (finalize) {
quote.win_streak++;
quote.votes = 0;
};
}; };
let count = winners.length; let count = winners.length;