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.
This commit is contained in:
trotFunky 2024-07-23 21:47:18 +01:00
parent dc00e22dba
commit b6f3a49e9f

View file

@ -126,7 +126,9 @@ pub async fn fetch_vote_data(week: u8, mut db: Connection<database::Db>) -> Opti
let votes_for_player: &mut Vec<u8> = match vote_data.entry(raw_vote.votes_for) {
Entry::Occupied(existing) => {existing.into_mut()}
Entry::Vacant(vacant) => {vacant.insert(Vec::<u8>::new())}
Entry::Vacant(vacant) => {
next_truth_number = 1; // We changed user, reset to 1.
vacant.insert(Vec::<u8>::new())}
};
// Fill up missing spaces if we are missing any.