Skip to content

Commit

Permalink
fix: Only update open or rollover positions
Browse files Browse the repository at this point in the history
Without that fix we were updating all positions of the user!
  • Loading branch information
holzeis committed Sep 19, 2023
1 parent 48e857a commit 63932dc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions coordinator/src/db/positions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ impl Position {
) -> Result<()> {
let affected_rows = diesel::update(positions::table)
.filter(positions::trader_pubkey.eq(trader_pubkey))
.filter(positions::position_state.eq(PositionState::Rollover))
.set((
positions::position_state.eq(PositionState::Open),
positions::temporary_contract_id.eq(temporary_contract_id.to_hex()),
Expand Down Expand Up @@ -169,6 +170,7 @@ impl Position {
) -> Result<()> {
let affected_rows = diesel::update(positions::table)
.filter(positions::trader_pubkey.eq(trader_pubkey))
.filter(positions::position_state.eq(PositionState::Open))
.set((
positions::expiry_timestamp.eq(expiry_timestamp),
positions::position_state.eq(PositionState::Rollover),
Expand Down

0 comments on commit 63932dc

Please sign in to comment.