From 9a181367c129f7a08f84c025047abdf43ca58095 Mon Sep 17 00:00:00 2001 From: Yarne Coppens Date: Sat, 31 Aug 2024 09:17:01 +0200 Subject: [PATCH] Winrate over time incluces today --- src/modules/statistic_creator.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/modules/statistic_creator.py b/src/modules/statistic_creator.py index 7f2b31c..f147b5b 100644 --- a/src/modules/statistic_creator.py +++ b/src/modules/statistic_creator.py @@ -375,6 +375,19 @@ def get_winrate_over_time(session: Session, player_name: str | None = None, day_ else: timeline_dict[current_date] = 0 + current_date == date.today() + playplayers_at_date = list(filter(lambda playplayer: playplayer.play.play_date <= current_date, all_playplayers)) + total_games_played = len(playplayers_at_date) + total_games_won = 0 + for playplayer in playplayers_at_date: + if playplayer.has_won: + total_games_won += 1 + + if total_games_played != 0: + timeline_dict[current_date] = total_games_won / total_games_played + else: + timeline_dict[current_date] = 0 + statistic_dict = { 'name': statistic_name,