fix: guard paperdex dupe detection against None API response
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m19s

db_get returns None on API errors. Added None guard and fixed
dupe count math to use max(0, count - 1) instead of ternary
that produced -1 dupes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-03-22 23:38:13 -05:00
parent 57a64127ba
commit 1c03d91478

View File

@ -181,11 +181,19 @@ async def get_card_embeds(card, include_stats=False) -> list:
name="Collected By", value=f"{count} team{'s' if count != 1 else ''}"
)
if card['team']['lname'] != 'Paper Dynasty':
team_dex = await db_get('cards', params=[("player_id", card["player"]["player_id"]), ('team_id', card['team']['id'])])
copy_count = team_dex['count'] if team_dex['count'] else 1
dupe_count = copy_count - 1
embed.add_field(name='Dupes', value=f'{dupe_count} dupe{"s" if dupe_count != 1 else ""}')
if card["team"]["lname"] != "Paper Dynasty":
team_dex = await db_get(
"cards",
params=[
("player_id", card["player"]["player_id"]),
("team_id", card["team"]["id"]),
],
)
if team_dex is not None:
dupe_count = max(0, team_dex["count"] - 1)
embed.add_field(
name="Dupes", value=f"{dupe_count} dupe{'s' if dupe_count != 1 else ''}"
)
# embed.add_field(name='Team', value=f'{card["player"]["mlbclub"]}')
if card["player"]["franchise"] != "Pokemon":