fix: preserve unmanaged first-seen timestamps
Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
co-authored by
genichin
parent
be2e73a2d6
commit
f9284d1de8
@@ -58,11 +58,11 @@ class PostgreSQLUnmanagedPositionStore:
|
||||
cur.execute(
|
||||
"UPDATE unmanaged_position_state "
|
||||
"SET quantity = %s, lifecycle_state = 'active', "
|
||||
" first_seen_at = %s, last_seen_at = %s, quantity_changed_at = %s, "
|
||||
" resolved_at = NULL, updated_at = %s "
|
||||
" last_seen_at = %s, quantity_changed_at = %s, resolved_at = NULL, "
|
||||
" updated_at = %s "
|
||||
"WHERE instance_key = %s AND symbol = %s "
|
||||
f"RETURNING {_STATE_COLUMNS}",
|
||||
(quantity, now, now, now, now, instance_key, symbol),
|
||||
(quantity, now, now, now, instance_key, symbol),
|
||||
)
|
||||
elif int(previous["quantity"]) != int(quantity):
|
||||
transition = "quantity_changed"
|
||||
|
||||
@@ -629,7 +629,9 @@ class InMemoryUnmanagedPositionStore:
|
||||
"symbol": symbol,
|
||||
"quantity": quantity,
|
||||
"lifecycle_state": "active",
|
||||
"first_seen_at": now,
|
||||
"first_seen_at": (
|
||||
existing.get("first_seen_at", now) if existing is not None else now
|
||||
),
|
||||
"last_seen_at": now,
|
||||
"quantity_changed_at": now,
|
||||
"resolved_at": None,
|
||||
|
||||
Reference in New Issue
Block a user