Skip to content

Commit

Permalink
Update positions.update_timestamp upon updated
Browse files Browse the repository at this point in the history
  • Loading branch information
da-kami committed Jul 20, 2023
1 parent 95d4ca8 commit 4364614
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion coordinator/src/db/positions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)?;

Expand Down

0 comments on commit 4364614

Please sign in to comment.