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,