Compare commits

..

14 Commits

Author SHA1 Message Date
ІМ-24 Владислав Коваленко d073243c67 refactor: use try block for error handling and session rollback
Component testing / Hub testing (push) Successful in 23s
Component testing / Store testing (push) Successful in 30s
Component testing / Integration smoke testing (push) Successful in 2m28s
2026-03-26 14:07:37 +00:00
ІМ-24 Владислав Коваленко 0d364ddf61 fix: remove visibility update from PUT endpoint 2026-03-26 14:07:37 +00:00
ІМ-24 Владислав Коваленко 05c94bda81 feat: update visibility field with websocket 2026-03-26 14:07:37 +00:00
ІМ-24 Владислав Коваленко 26230df612 feat: add schema for receiving data from websocker 2026-03-26 14:07:37 +00:00
ІМ-24 Владислав Коваленко ae10e212cb fix: remove visible from schemas, so only store knows about it 2026-03-26 14:07:37 +00:00
ІМ-24 Владислав Коваленко e2e68e8506 fix: add visible columnt to .sql init script 2026-03-26 14:07:37 +00:00
ІМ-24 Владислав Коваленко 1375e6e4be feat: add visibility field to database table 2026-03-26 14:07:37 +00:00
ІМ-24 Владислав Коваленко 154c5c3a78 feat: add visibility field 2026-03-26 14:07:37 +00:00
hasslesstech 1f6b02c5f6 [P] Add a simple .gpx to .csv file converter
Component testing / Hub testing (push) Successful in 33s
Component testing / Store testing (push) Successful in 32s
Component testing / Integration smoke testing (push) Successful in 3m0s
2026-03-25 23:39:32 +02:00
hasslesstech 69523a9fd2 [P] Reduce batch size to improve viewing experience
Component testing / Hub testing (push) Successful in 25s
Component testing / Integration smoke testing (push) Has been cancelled
Component testing / Store testing (push) Has been cancelled
2026-03-25 23:35:24 +02:00
hasslesstech 094662f59e [P] Add second agent in docker-compose.yaml
Component testing / Hub testing (push) Has been cancelled
Component testing / Store testing (push) Has been cancelled
Component testing / Integration smoke testing (push) Has been cancelled
2026-03-25 23:27:59 +02:00
hasslesstech 88454f381d [P] Add GPS file selection to agent 2026-03-25 23:27:59 +02:00
hasslesstech 119547d288 [P] Add TRACK_ID selection in MapView
Component testing / Hub testing (push) Successful in 41s
Component testing / Store testing (push) Successful in 24s
Component testing / Integration smoke testing (push) Successful in 2m30s
2026-03-25 23:27:20 +02:00
hasslesstech b58167f0de [P] Fix wrong row sending order
Component testing / Hub testing (push) Successful in 35s
Component testing / Store testing (push) Successful in 26s
Component testing / Integration smoke testing (push) Successful in 2m37s
2026-03-25 23:26:39 +02:00
5 changed files with 44 additions and 6 deletions
+13
View File
@@ -0,0 +1,13 @@
print('lat,lon')
try:
while True:
i = input()
if '<trkpt' not in i:
continue
si = i.split('"')[1::2]
print(f"{si[0]},{si[1]}")
except EOFError:
pass
+1 -1
View File
@@ -148,7 +148,7 @@ services:
MQTT_BROKER_HOST: "mqtt"
MQTT_BROKER_PORT: 1883
MQTT_TOPIC: "processed_data_topic"
BATCH_SIZE: 20
BATCH_SIZE: 4
ports:
- "9000:8000"
networks:
+3 -2
View File
@@ -7,5 +7,6 @@ CREATE TABLE processed_agent_data (
z FLOAT,
latitude FLOAT,
longitude FLOAT,
timestamp TIMESTAMP
);
timestamp TIMESTAMP,
visible BOOLEAN
);
+23 -3
View File
@@ -8,12 +8,13 @@ from sqlalchemy import (
Integer,
String,
Float,
Boolean,
DateTime,
)
from sqlalchemy.sql import select
from database import metadata, SessionLocal
from schemas import ProcessedAgentData, ProcessedAgentDataInDB
from schemas import ProcessedAgentData, ProcessedAgentDataInDB, WebSocketData
# FastAPI app setup
app = FastAPI()
@@ -30,6 +31,7 @@ processed_agent_data = Table(
Column("latitude", Float),
Column("longitude", Float),
Column("timestamp", DateTime),
Column("visible", Boolean),
)
# WebSocket subscriptions
@@ -45,7 +47,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]
@@ -57,7 +59,24 @@ async def websocket_endpoint(websocket: WebSocket, user_id: int):
# receive forever
while True:
await websocket.receive_text()
data = await websocket.receive_text()
try:
if (data):
ws_data = WebSocketData.model_validate(json.loads(data))
session = SessionLocal()
update_query = (
processed_agent_data.update()
.where(processed_agent_data.c.id == ws_data.id)
.values(visible=False)
).returning(processed_agent_data)
res = session.execute(update_query).fetchone()
if (not res):
session.rollback()
raise Exception("Error while websocket PUT")
session.commit()
finally:
session.close()
except WebSocketDisconnect:
subscriptions.remove(websocket)
@@ -81,6 +100,7 @@ def ProcessedAgentData_to_td(data: List[ProcessedAgentData]):
"latitude": item.agent_data.gps.latitude,
"longitude": item.agent_data.gps.longitude,
"timestamp": item.agent_data.timestamp,
"visible": True,
}
for item in data
]
+4
View File
@@ -49,3 +49,7 @@ class AgentData(BaseModel):
class ProcessedAgentData(BaseModel):
road_state: str
agent_data: AgentData
class WebSocketData(BaseModel):
id: int