fix: sort /teams/{id}/evolutions by current_tier desc, current_value desc (#116) #120
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-merged
ai-pr-opened
ai-reviewed
ai-reviewing
ai-reviewing
ai-working
bug
enhancement
evolution
performance
phase-0
phase-1a
phase-1b
phase-1c
phase-1d
security
tech-debt
todo
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-database#120
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/paper-dynasty-database-116"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #116
Summary
.order_by(EvolutionCardState.player_id)to.order_by(current_tier DESC, current_value DESC)inlist_team_evolutions/evo statuswithout needing thetier:1filterFiles changed
app/routers_v2/teams.py— order_by clause inlist_team_evolutionsTest results
117 passed, 15 skipped — all green.
AI Code Review
Files Reviewed
app/routers_v2/teams.py(modified)Findings
Correctness
EvolutionCardState.current_tierandcurrent_valueare both confirmed fields on the model (IntegerField(default=0)andFloatField(default=0.0)respectively)..desc()is valid Peewee syntax..switch(EvolutionCardState).join(Player)is the right Peewee pattern for multi-table joins after already joiningEvolutionTrack.Playeris added to.select()sostate.playeris eagerly loaded — no N+1.state.player.p_nameis safe:playerFK onEvolutionCardStateis non-nullable, and the inner join ensures only rows with valid player references are returned.query.count()— Peewee wraps the full query as a subquery for count, all filters apply before.offset().limit().Security
valid_token) is unchanged. No user input flows into the join or ordering logic.Style & Conventions
Playeris added to the lazy import block inside the function body, butPlayeris already imported at module level (line 18). The redundant lazy import is harmless — Python's module cache means it resolves to the same object — but it's unnecessary. Minor nit only.team_buy_players) is trivial whitespace; not a concern.Suggestions
current_tier DESC, current_value DESC) is not fully deterministic when two cards share the same tier and value. Adding.order_by(..., EvolutionCardState.player_id)as a tiebreaker would restore stable pagination. Low priority for the/evo statususe case, but worth considering if pagination is used.Playerinfrom ..db_engine import EvolutionCardState, EvolutionTrack, Playeris already in scope from the module-level import. Not harmful, just slightly noisy.player_namechanges (from PR #119's branch) in addition to the ordering change. The PR body only describes the ordering change. Not a code issue, but the combined scope could cause confusion on review.Verdict: APPROVED
Clean fix. The ordering change is correct, the Player join follows the codebase's established Peewee multi-join pattern, and eager loading is properly handled. No correctness or security issues.
Automated review by Claude PR Reviewer
2884c07aebto0953a45b9f