perf: N+1 sequential API calls in schedule_service (up to 18 per request) #88
Labels
No Label
ai-changes-requested
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
in-next-release
status/in-progress
status/pr-open
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-v2#88
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
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?
Problem
schedule_service.pyfetches game data one week at a time in a loop, issuing up to 18 sequential HTTP requests.get_team_schedule()lines 84–121For a full-season view with no
weeksargument, this fires 18 sequential HTTP requests.get_recent_games()lines 123–158Loops over 2 weeks sequentially.
get_upcoming_games()lines 160–196Loops over up to 18 weeks sequentially with early-exit heuristic.
Fix
Option A: Use
asyncio.gather()across all week fetches:Option B (better): Add a single API endpoint/param that returns games filtered by team across all weeks, eliminating the per-week loop entirely.
Impact
HIGH —
/scheduleis a common user command. 18 serial round-trips at ~100ms each = ~1.8 seconds of avoidable latency.PR #103 opened: #103
Replaced all three sequential week-fetch loops with
asyncio.gather()—get_team_schedule(),get_recent_games(), andget_upcoming_games(). Also added the missingimport asyncio. 16 new tests added covering the parallelization behavior.