Compare commits

..

6 Commits

Author SHA1 Message Date
Cal Corum
0953a45b9f fix: sort /teams/{id}/evolutions by current_tier desc, current_value desc (#116)
Closes #116

The endpoint was returning results in player_id insertion order, causing
/evo status in Discord to show a wall of T0/value-0 cards before any
progressed players. Sort by current_tier DESC, current_value DESC so
the most-evolved cards always appear first.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 13:24:14 -05:00
cal
87f46a1bfd Merge pull request 'docs: update list_team_evolutions docstring for player_name and Player join' (#121) from ai/paper-dynasty-database#115 into next-release
Some checks are pending
Build Docker Image / build (push) Waiting to run
Reviewed-on: #121
2026-03-19 18:22:22 +00:00
Cal Corum
8733fd45ad docs: update list_team_evolutions docstring for player_name and Player join
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 13:20:57 -05:00
cal
57d8a929fd Merge pull request 'fix: include player_name in /teams/{id}/evolutions response (#115)' (#119) from ai/paper-dynasty-database#115 into next-release
Some checks are pending
Build Docker Image / build (push) Waiting to run
Reviewed-on: #119
Reviewed-by: cal <cal@manticorum.com>
2026-03-19 18:20:18 +00:00
cal
a81bde004b Merge pull request 'fix: season-stats update-game returns 404 for nonexistent game_id' (#117) from ai/paper-dynasty-database#113 into next-release
Some checks failed
Build Docker Image / build (push) Has been cancelled
Reviewed-on: #117
2026-03-19 18:18:39 +00:00
Cal Corum
3fc6721d4d fix: catch DoesNotExist and return 404 for nonexistent game_id
Closes #113

Adds a specific `DoesNotExist` handler before the generic `Exception`
block in `update_game_season_stats`. Peewee's `DoesNotExist` (raised
when `StratGame.get_by_id(game_id)` finds no row) previously bubbled
through to the `except Exception` handler which included raw SQL and
params in the 500 detail string. Now returns a clean 404.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-19 12:01:46 -05:00
2 changed files with 10 additions and 5 deletions

View File

@ -52,9 +52,12 @@ async def update_game_season_stats(
raise HTTPException(status_code=401, detail="Unauthorized")
from ..services.season_stats import update_season_stats
from ..db_engine import DoesNotExist
try:
result = update_season_stats(game_id, force=force)
except DoesNotExist:
raise HTTPException(status_code=404, detail=f"Game {game_id} not found")
except Exception as exc:
logger.error("update-game/%d failed: %s", game_id, exc, exc_info=True)
raise HTTPException(

View File

@ -1541,10 +1541,11 @@ async def list_team_evolutions(
):
"""List all EvolutionCardState rows for a team, with optional filters.
Joins EvolutionCardState to EvolutionTrack so that card_type filtering
works without a second query. Results are paginated via page/per_page
(1-indexed pages); items are ordered by current_tier DESC, current_value DESC
so the most-progressed cards appear first.
Joins EvolutionCardState EvolutionTrack (for card_type filtering and
threshold context) and EvolutionCardState Player (for player_name),
both eager-loaded in a single query. Results are paginated via
page/per_page (1-indexed pages); items are ordered by current_tier DESC,
current_value DESC so the most-progressed cards appear first.
Query parameters:
card_type -- filter to states whose track.card_type matches (e.g. 'batter', 'sp')
@ -1555,7 +1556,8 @@ async def list_team_evolutions(
Response shape:
{"count": N, "items": [card_state_with_threshold_context, ...]}
Each item in 'items' has the same shape as GET /evolution/cards/{card_id}.
Each item in 'items' has the same shape as GET /evolution/cards/{card_id},
plus a ``player_name`` field sourced from the Player table.
"""
if not valid_token(token):
logging.warning("Bad Token: [REDACTED]")