Winrate over time incluces today

This commit is contained in:
Yarne Coppens 2024-08-31 09:17:01 +02:00
parent 61d7abd7f3
commit 9a181367c1

View file

@ -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,