From b58167f0de3d36ef3f4ac4d74367c42f4a93d2f8 Mon Sep 17 00:00:00 2001 From: hasslesstech Date: Wed, 25 Mar 2026 22:27:40 +0200 Subject: [PATCH] [P] Fix wrong row sending order --- store/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/store/main.py b/store/main.py index f871c1c..94ea9f7 100644 --- a/store/main.py +++ b/store/main.py @@ -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: -- 2.49.1