Merge pull request 'fix: re-fetch existing transactions on each validation' (#72) from fix/refresh-existing-transactions-on-validation into next-release
Reviewed-on: #72
This commit is contained in:
commit
541380acdf
@ -201,9 +201,8 @@ class TransactionBuilder:
|
|||||||
self._current_roster: Optional[TeamRoster] = None
|
self._current_roster: Optional[TeamRoster] = None
|
||||||
self._roster_loaded = False
|
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: Optional[List[Transaction]] = None
|
||||||
self._existing_transactions_loaded = False
|
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"TransactionBuilder initialized for {team.abbrev} by user {user_id}"
|
f"TransactionBuilder initialized for {team.abbrev} by user {user_id}"
|
||||||
@ -233,11 +232,12 @@ class TransactionBuilder:
|
|||||||
"""
|
"""
|
||||||
Load pre-existing transactions for next week.
|
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
|
Queries for all organizational affiliates (ML, MiL, IL) to ensure
|
||||||
trades involving affiliate teams are included in roster projections.
|
trades involving affiliate teams are included in roster projections.
|
||||||
"""
|
"""
|
||||||
if self._existing_transactions_loaded:
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Include all org affiliates so trades involving MiL/IL teams are captured
|
# Include all org affiliates so trades involving MiL/IL teams are captured
|
||||||
@ -252,14 +252,12 @@ class TransactionBuilder:
|
|||||||
week_start=next_week,
|
week_start=next_week,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self._existing_transactions_loaded = True
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"Loaded {len(self._existing_transactions or [])} existing transactions for {self.team.abbrev} org ({org_abbrevs}) week {next_week}"
|
f"Loaded {len(self._existing_transactions or [])} existing transactions for {self.team.abbrev} org ({org_abbrevs}) week {next_week}"
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to load existing transactions: {e}")
|
logger.error(f"Failed to load existing transactions: {e}")
|
||||||
self._existing_transactions = []
|
self._existing_transactions = []
|
||||||
self._existing_transactions_loaded = True
|
|
||||||
|
|
||||||
async def add_move(
|
async def add_move(
|
||||||
self,
|
self,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user