perf: double API calls in trade views (validate_trade and _get_user_team) #94
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#94
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
Two methods in
views/trade_embed.pymake redundant API calls per user interaction.create_trade_embed—validate_trade()called twice (lines 714, 769)First call at line 714 determines embed color, second call at line 769 gets status text. Each
validate_trade()hits roster API + transactions API per participant. On every button interaction (Remove Move, Cancel, navigation), this doubles the API cost.TradeAcceptanceView—_get_user_team()called twice per button clickinteraction_check(line 341) calls it to verify the user is a participant — discards the team objectaccept_buttonline 369,reject_buttonline 404) call it again to get the team for processingFix
validate_trade
Call once, store the result:
_get_user_team
Store the team on the view instance after
interaction_checksucceeds:Impact
MEDIUM — Trade builder is interactive with multiple button clicks. Each click currently makes 2x the necessary API calls.
PR opened: #116
Fix 1 —
create_trade_embed: moved the singlevalidate_trade()call before theif builder.is_emptyblock; both color selection and status text now share the result, eliminating the second call.Fix 2 —
TradeAcceptanceView:interaction_checkstores the resolved team inself._checked_teamafter validating the user is a participant;accept_buttonandreject_buttonread fromself._checked_teaminstead of calling_get_user_team()again.