Skip to content

Commit

Permalink
Handle StopIteration exception in get_daily_matches to return an empt…
Browse files Browse the repository at this point in the history
…y list
  • Loading branch information
raimannma committed Feb 13, 2025
1 parent 07cdeb6 commit 8cd25fa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion deadlock_data_api/routers/v1_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ def next_match_generator(account_id: int) -> Generator[PlayerMatchHistoryEntry,

def get_daily_matches(account_id: int) -> list[PlayerMatchHistoryEntry]:
match_history = peekable(next_match_generator(account_id))
first_match = match_history.peek()
try:
first_match = match_history.peek()
except StopIteration:
return []

# If the first match is older than 8 hours ago, we can assume that the player has no matches today
if first_match.start_time < int((datetime.now() - timedelta(hours=8)).timestamp()):
Expand Down

0 comments on commit 8cd25fa

Please sign in to comment.