From c339e965786c3c31d1e31d9b28530f66afa302e0 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Thu, 23 Sep 2021 17:40:08 -0600 Subject: [PATCH] Fix the winners endpoint resetting the quote votes before comparison --- src/endpoints/management/winners.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/endpoints/management/winners.ts b/src/endpoints/management/winners.ts index 6bada9e..71c46c0 100644 --- a/src/endpoints/management/winners.ts +++ b/src/endpoints/management/winners.ts @@ -22,11 +22,6 @@ const route: ServerRoute = { // Run through all of the quotes to find the most voted for ones for (var quote of data.quotes) { - if (finalize) { - quote.win_streak++; - quote.votes = 0; - }; - // New maximum, remove all previous winners if (quote.votes > highest) { winners = [ quote ]; @@ -36,6 +31,12 @@ const route: ServerRoute = { else if (quote.votes === highest) { winners.push( quote ); }; + + // Reset the bracket data as needed + if (finalize) { + quote.win_streak++; + quote.votes = 0; + }; }; let count = winners.length;