Skip to content

Commit

Permalink
feat: apply change requests
Browse files Browse the repository at this point in the history
  • Loading branch information
vestor-dev committed Nov 25, 2024
1 parent 93c272d commit 2f21dc3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions web_app/db/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ def liquidate_position(self, position_id: int) -> bool:
logger.error(f"Error liquidating position {position_id}: {str(e)}")
db.rollback()
return False

def get_all_liquidated_positions(self) -> list[dict]:
"""
Retrieves all positions where `is_liquidated` is True.
Expand All @@ -513,21 +514,18 @@ def get_all_liquidated_positions(self) -> list[dict]:
db.query(Position)
.filter(Position.is_liquidated == True)
.all()
)
).scalar()

# Convert ORM objects to dictionaries for return
return [
{
"id": position.id,
"user_id": position.user_id,
"token_symbol": position.token_symbol,
"amount": position.amount,
"multiplier": position.multiplier,
"created_at": position.created_at,
"status": position.status.value,
"start_price": position.start_price,
"is_protection": position.is_protection,
"liquidation_bonus": position.liquidation_bonus,
"is_liquidated": position.is_liquidated,
"datetime_liquidation": position.datetime_liquidation
}
Expand Down

0 comments on commit 2f21dc3

Please sign in to comment.