Batch BattingCard/BattingCardRatings lookups in lineup endpoints #18

Closed
opened 2026-02-20 06:52:43 +00:00 by cal · 1 comment
Owner

`app/routers_v2/teams.py` — `get_bratings` helper (line 373) and `get_scouting_dfs` each call `get_or_none` for every individual player during lineup construction.

Priority: medium

\`app/routers_v2/teams.py\` — \`get_bratings\` helper (line 373) and \`get_scouting_dfs\` each call \`get_or_none\` for every individual player during lineup construction. **Priority**: medium
cal added the
performance
label 2026-02-20 06:52:43 +00:00
cal added the
ai-working
label 2026-03-03 23:31:16 +00:00
cal removed the
ai-working
label 2026-03-03 23:34:44 +00:00
Author
Owner

Fixed in PR #45.

Replaced the per-player get_or_none() calls inside get_bratings() with two bulk SELECT queries executed once before the position loop — one for BattingCard, one for BattingCardRatings. Both are stored in dicts keyed by player_id / card+hand, reducing DB round trips from O(3N) to O(2) per lineup build.

Fixed in PR #45. Replaced the per-player `get_or_none()` calls inside `get_bratings()` with two bulk SELECT queries executed once before the position loop — one for `BattingCard`, one for `BattingCardRatings`. Both are stored in dicts keyed by player_id / card+hand, reducing DB round trips from O(3N) to O(2) per lineup build.
cal added the
ai-pr-opened
label 2026-03-03 23:34:53 +00:00
cal closed this issue 2026-03-07 03:16:14 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/paper-dynasty-database#18
No description provided.