fix: re-fetch existing transactions on each validation #72
@ -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