fix: re-fetch existing transactions on each validation
The TransactionBuilder cached pre-existing transactions on first load and never refreshed them. This meant transactions submitted by other sessions (or newly visible after API fixes) were invisible for the lifetime of the builder session, causing incorrect roster projections. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
ee324693b1
commit
556a30c397
@ -201,9 +201,8 @@ class TransactionBuilder:
|
||||
self._current_roster: Optional[TeamRoster] = None
|
||||
self._roster_loaded = False
|
||||
|
||||
# Cache for pre-existing transactions
|
||||
# Pre-existing transactions (re-fetched on each validation)
|
||||
self._existing_transactions: Optional[List[Transaction]] = None
|
||||
self._existing_transactions_loaded = False
|
||||
|
||||
logger.info(
|
||||
f"TransactionBuilder initialized for {team.abbrev} by user {user_id}"
|
||||
@ -233,11 +232,12 @@ class TransactionBuilder:
|
||||
"""
|
||||
Load pre-existing transactions for next week.
|
||||
|
||||
Always re-fetches from the API to capture transactions submitted
|
||||
by other users or sessions since the builder was initialized.
|
||||
|
||||
Queries for all organizational affiliates (ML, MiL, IL) to ensure
|
||||
trades involving affiliate teams are included in roster projections.
|
||||
"""
|
||||
if self._existing_transactions_loaded:
|
||||
return
|
||||
|
||||
try:
|
||||
# Include all org affiliates so trades involving MiL/IL teams are captured
|
||||
@ -252,14 +252,12 @@ class TransactionBuilder:
|
||||
week_start=next_week,
|
||||
)
|
||||
)
|
||||
self._existing_transactions_loaded = True
|
||||
logger.debug(
|
||||
f"Loaded {len(self._existing_transactions or [])} existing transactions for {self.team.abbrev} org ({org_abbrevs}) week {next_week}"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to load existing transactions: {e}")
|
||||
self._existing_transactions = []
|
||||
self._existing_transactions_loaded = True
|
||||
|
||||
async def add_move(
|
||||
self,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user