File tree Expand file tree Collapse file tree
diracx-routers/src/diracx/routers/pilot_logging Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from __future__ import annotations
22
33from pydantic import BaseModel
4+ from sqlalchemy import select
5+
6+ from diracx .db .sql .pilot_agents .schema import PilotAgents
7+ from diracx .db .sql .utils import BaseSQLDB
48
59from ..dependencies import PilotLogsDB
610from ..fastapi_classes import DiracxRouter
@@ -30,7 +34,17 @@ async def send_message(
3034 logger .warning (f"Message received '{ data } '" )
3135 await check_permissions (action = ActionType .CREATE , pilot_db = pilot_logs_db )
3236
33- pilot_id = 1234 # need to get pilot id from pilot_stamp (via pilot DB)
37+ pilot_id = 0 # need to get pilot id from pilot_stamp (via PilotAgentsDB)
38+ piloAgentsDB = BaseSQLDB .available_implementations ("PilotAgentsDB" )[0 ]
39+ url = BaseSQLDB .available_urls ()["PilotAgentsDB" ]
40+ db = piloAgentsDB (url )
41+
42+ async with db .engine_context ():
43+ async with db :
44+ stmt = select (
45+ (PilotAgents .PilotID ).where (PilotAgents .PilotStamp == data .pilot_stamp )
46+ )
47+ pilot_id = (await db .conn .execute (stmt )).scalar_one ()
3448
3549 docs = []
3650 for line in data .lines :
You can’t perform that action at this time.
0 commit comments