From 9f803898f3489a1857188125694e64ec59c91ec4 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sun, 24 Nov 2024 17:44:30 +0000 Subject: [PATCH] Skip counting votes for fully banned members. --- presidential-election.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/presidential-election.js b/presidential-election.js index 50da038..1844de5 100644 --- a/presidential-election.js +++ b/presidential-election.js @@ -250,6 +250,7 @@ async function CountVotesAndAwardPresidency() { const voteList = {}; const voteSum = {}; let voteCount = 0; + let validVoteCount = 0; let maxSum = 0; const users = UserCache.GetAllUsersAsFlatList(); for (const user of users) { @@ -265,13 +266,16 @@ async function CountVotesAndAwardPresidency() { voteSum[v] = 0; voteList[v] = []; } - voteSum[v] += weight; - voteList[v].push({ color, weight }); voteCount++; - maxSum = Math.max(voteSum[v], maxSum); + if (!user.ban_conviction_time) { + validVoteCount++; + voteSum[v] += weight; + voteList[v].push({ color, weight }); + maxSum = Math.max(voteSum[v], maxSum); + } } } - if (!voteCount) { + if (!validVoteCount) { return; } const sortableCandidates = [];