feature/boss-sprites-and-badges (#22)
All checks were successful
CI / backend-lint (push) Successful in 8s
CI / frontend-lint (push) Successful in 32s

Reviewed-on: TheFurya/nuzlocke-tracker#22
Co-authored-by: Julian Tabel <juliantabel.jt@gmail.com>
Co-committed-by: Julian Tabel <juliantabel.jt@gmail.com>
This commit was merged in pull request #22.
This commit is contained in:
2026-02-14 11:04:08 +01:00
committed by TheFurya
parent 3412d6c6fd
commit ebdc9b2f28
225 changed files with 879 additions and 130 deletions

View File

@@ -239,6 +239,7 @@ async def upsert_bosses(
bosses: list[dict],
dex_to_id: dict[int, int],
route_name_to_id: dict[str, int] | None = None,
slug_to_game_id: dict[str, int] | None = None,
) -> int:
"""Upsert boss battles for a version group, return count of bosses upserted."""
count = 0
@@ -253,6 +254,16 @@ async def upsert_bosses(
f" Warning: route '{after_route_name}' not found for boss '{boss['name']}'"
)
# Resolve game_slug to game_id
game_id = None
game_slug = boss.get("game_slug")
if game_slug and slug_to_game_id:
game_id = slug_to_game_id.get(game_slug)
if game_id is None:
print(
f" Warning: game '{game_slug}' not found for boss '{boss['name']}'"
)
# Upsert the boss battle on (version_group_id, order) conflict
stmt = (
insert(BossBattle)
@@ -269,6 +280,7 @@ async def upsert_bosses(
location=boss["location"],
section=boss.get("section"),
sprite_url=boss.get("sprite_url"),
game_id=game_id,
)
.on_conflict_do_update(
constraint="uq_boss_battles_version_group_order",
@@ -283,6 +295,7 @@ async def upsert_bosses(
"location": boss["location"],
"section": boss.get("section"),
"sprite_url": boss.get("sprite_url"),
"game_id": game_id,
},
)
.returning(BossBattle.id)