Skip to content

Commit

Permalink
Handle division by zero in winrate calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
raimannma committed Jan 29, 2025
1 parent 903b2ef commit 9c13fd0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions deadlock_data_api/routers/v1_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ def winrate_today(self, account_id: int, *args, **kwargs) -> str:
"""Get the winrate today"""
wins = int(self.wins_today(account_id))
losses = int(self.losses_today(account_id))
if wins + losses == 0:
return "0.00%"
return f"{wins / (wins + losses):.2%}"

def wins_losses_today(self, account_id: int, *args, **kwargs) -> str:
Expand Down

0 comments on commit 9c13fd0

Please sign in to comment.