From 4364614fbd33be3e080d493b89814344d646ae9c Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Thu, 20 Jul 2023 17:44:54 +1000 Subject: [PATCH] Update `positions.update_timestamp` upon updated --- coordinator/src/db/positions.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/coordinator/src/db/positions.rs b/coordinator/src/db/positions.rs index fe1f158ef..68ec95dce 100644 --- a/coordinator/src/db/positions.rs +++ b/coordinator/src/db/positions.rs @@ -97,7 +97,10 @@ impl Position { let effected_rows = diesel::update(positions::table) .filter(positions::trader_pubkey.eq(trader_pubkey.clone())) .filter(positions::position_state.eq(PositionState::Open)) - .set(positions::position_state.eq(PositionState::Closing)) + .set(( + positions::position_state.eq(PositionState::Closing), + positions::update_timestamp.eq(OffsetDateTime::now_utc()), + )) .execute(conn)?; if effected_rows == 0 { @@ -117,6 +120,7 @@ impl Position { .set(( positions::position_state.eq(PositionState::Closed), positions::realized_pnl.eq(Some(pnl)), + positions::update_timestamp.eq(OffsetDateTime::now_utc()), )) .execute(conn)?;