fix: close broker uncertainty audit gaps
This commit is contained in:
@@ -341,6 +341,8 @@ class PostgreSQLSlotRepository:
|
||||
slot_id: UUID,
|
||||
broker_order_id: str,
|
||||
state: str,
|
||||
*,
|
||||
only_if_unset: bool = False,
|
||||
) -> bool:
|
||||
now = datetime.now(tz=timezone.utc)
|
||||
with self._psycopg.connect(self._dsn, autocommit=False) as conn:
|
||||
@@ -349,8 +351,16 @@ class PostgreSQLSlotRepository:
|
||||
"UPDATE daily_slot SET cancel_state=%s, "
|
||||
"cancel_requested_at=%s, updated_at=%s "
|
||||
"WHERE slot_id=%s AND broker_order_id=%s "
|
||||
"AND status IN ('pending_buy','pending_sell')",
|
||||
(state, now, now, slot_id, broker_order_id),
|
||||
"AND status IN ('pending_buy','pending_sell') "
|
||||
"AND (%s = FALSE OR cancel_state IS NULL)",
|
||||
(
|
||||
state,
|
||||
now,
|
||||
now,
|
||||
slot_id,
|
||||
broker_order_id,
|
||||
only_if_unset,
|
||||
),
|
||||
)
|
||||
ok = cur.rowcount == 1
|
||||
conn.commit()
|
||||
|
||||
Reference in New Issue
Block a user