project/shmuliar-FIX-07-wrong-row-order #31

Merged
Vladislav merged 1 commits from project/shmuliar-FIX-07-wrong-row-order into dev 2026-03-26 10:17:00 +02:00
Showing only changes of commit b58167f0de - Show all commits

View File

@@ -45,7 +45,7 @@ async def websocket_endpoint(websocket: WebSocket, user_id: int):
try:
# send already available data
r = processed_agent_data.select()
r = processed_agent_data.select().order_by(processed_agent_data.c.timestamp)
stored_data = SessionLocal().execute(r).fetchall()
jsonable_data = [{c.name: getattr(i, c.name) for c in processed_agent_data.columns} for i in stored_data]
@@ -96,7 +96,7 @@ async def create_processed_agent_data(data: List[ProcessedAgentData], user_id: i
created_records = [dict(row._mapping) for row in result.fetchall()]
session.commit()
for record in created_records:
for record in sorted(created_records, key = lambda x: x['timestamp']):
await send_data_to_subscribers(jsonable_encoder(record))
return created_records
except Exception as err: