From b6f3a49e9f304e1752d50cc6d49677e6cc136d29 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Tue, 23 Jul 2024 21:47:18 +0100 Subject: [PATCH] vote: Reset the truth counter to 1 if the key changes In order to fill the missing truths with 0, a counter follows the next expected truth number. If it suddenly drops down, we changed player and it should reset as well. However, as not all players are voted for on all truths, we might change players but get a higher truth, which was not taken into account and could miss all the zeroes at the beggining for this player. Reset the counter if we change players. --- src/vote.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vote.rs b/src/vote.rs index 395c06c..09239f6 100644 --- a/src/vote.rs +++ b/src/vote.rs @@ -126,7 +126,9 @@ pub async fn fetch_vote_data(week: u8, mut db: Connection) -> Opti let votes_for_player: &mut Vec = match vote_data.entry(raw_vote.votes_for) { Entry::Occupied(existing) => {existing.into_mut()} - Entry::Vacant(vacant) => {vacant.insert(Vec::::new())} + Entry::Vacant(vacant) => { + next_truth_number = 1; // We changed user, reset to 1. + vacant.insert(Vec::::new())} }; // Fill up missing spaces if we are missing any.