From 2884c07aeb639fde12e7dcca816ef565a367d840 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Thu, 19 Mar 2026 13:14:23 -0500 Subject: [PATCH] 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 --- app/routers_v2/teams.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/routers_v2/teams.py b/app/routers_v2/teams.py index 0a8f017..5177d92 100644 --- a/app/routers_v2/teams.py +++ b/app/routers_v2/teams.py @@ -1543,7 +1543,8 @@ async def list_team_evolutions( 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 player_id for stable ordering. + (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') @@ -1569,7 +1570,10 @@ async def list_team_evolutions( .switch(EvolutionCardState) .join(Player) .where(EvolutionCardState.team == team_id) - .order_by(EvolutionCardState.player_id) + .order_by( + EvolutionCardState.current_tier.desc(), + EvolutionCardState.current_value.desc(), + ) ) if card_type is not None: