From 556a30c3971c330e70cc5d484e9416d000259ded Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Mon, 9 Mar 2026 08:10:22 -0500 Subject: [PATCH] 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 --- services/transaction_builder.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/services/transaction_builder.py b/services/transaction_builder.py index 2aa879c..c33485b 100644 --- a/services/transaction_builder.py +++ b/services/transaction_builder.py @@ -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,