perf: autocomplete fires two API calls per keystroke; cache user team lookup #99
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
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-v2#99
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
utils/autocomplete.pyplayer_autocomplete(lines 38–41) makes two API calls on every keystroke:get_user_major_league_team(interaction)— looks up the user's teamplayer_service.search_players(query, limit=50)— searches for playersDiscord fires autocomplete on every character typed. The user's team membership changes extremely rarely but is fetched fresh every keystroke.
Additionally,
limit=50fetches twice as many results as Discord can display (max 25 choices).Fix
get_user_major_league_teamresult perinteraction.user.idwith a short TTL (60 seconds):limit=50tolimit=25to match Discord's display limit.Impact
MEDIUM — Autocomplete is the most latency-sensitive path in Discord. Slow autocomplete shows a visible spinner to users on every keystroke.