paper-dynasty-database/app/routers_v2
Cal Corum 4445acb7d0 fix: materialize final_players queryset before double-iteration in get_random_player
When no position filters are applied, `final_players` is a lazy Peewee queryset
with `ORDER BY RANDOM() LIMIT n`. Iterating it twice (once to build player_ids,
once for the response loop) executes two separate DB queries with different random
seeds, causing dex_by_player to be built for a different player set than returned,
silently producing empty paperdex for all players.

Add `final_players = list(final_players)` before building player_ids to ensure
both iterations operate on the same materialized result. Also fix pre-existing
syntax error in import statement and minor ruff lint issues in the same file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-10 14:03:26 -05:00
..
__init__.py Initial Commit with /current 2023-09-13 14:44:26 -05:00
admin.py fix: remove plaintext bearer token from warning logs (#7) 2026-03-05 03:43:27 +00:00
awards.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
batstats.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
battingcardratings.py fix: remove plaintext bearer token from warning logs (#7) 2026-03-05 03:43:27 +00:00
battingcards.py fix: remove plaintext bearer token from warning logs (#7) 2026-03-05 03:43:27 +00:00
cardpositions.py fix: remove plaintext bearer token from warning logs (#7) 2026-03-05 03:43:27 +00:00
cards.py fix: batch Paperdex lookups to avoid N+1 queries (#17) 2026-03-07 01:37:03 -06:00
cardsets.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
current.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
decisions.py fix: remove plaintext bearer token from warning logs (#7) 2026-03-05 03:43:27 +00:00
events.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
gamerewards.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
gauntletrewards.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
gauntletruns.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
mlbplayers.py fix: remove plaintext bearer token from warning logs (#7) 2026-03-05 03:43:27 +00:00
notifications.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
packs.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
packtypes.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
paperdex.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
pitchingcardratings.py fix: remove plaintext bearer token from warning logs (#7) 2026-03-05 03:43:27 +00:00
pitchingcards.py fix: remove plaintext bearer token from warning logs (#7) 2026-03-05 03:43:27 +00:00
pitstats.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
players.py fix: materialize final_players queryset before double-iteration in get_random_player 2026-03-10 14:03:26 -05:00
rarity.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
results.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
rewards.py fix: replace broad except Exception blocks with DoesNotExist (#15) 2026-03-05 15:32:53 -06:00
scout_claims.py feat: add scout_opportunities and scout_claims tables and API endpoints (#44) 2026-03-05 03:45:38 +00:00
scout_opportunities.py feat: add scout_opportunities and scout_claims tables and API endpoints (#44) 2026-03-05 03:45:38 +00:00
scouting.py fix: remove broken live_update_batting stub endpoint (#10) 2026-03-05 15:34:06 -06:00
stratgame.py fix: remove plaintext bearer token from warning logs (#7) 2026-03-05 03:43:27 +00:00
stratplays.py fix: remove plaintext bearer token from warning logs (#7) 2026-03-05 03:43:27 +00:00
teams.py Merge pull request 'fix: replace broad except Exception blocks with DoesNotExist (#15)' (#48) from ai/paper-dynasty-database#15 into next-release 2026-03-07 03:18:56 +00:00