Skip to content

Commit

Permalink
feat: add pilotID from pilot stamp (needs PilotAgents schema)
Browse files Browse the repository at this point in the history
  • Loading branch information
martynia committed Oct 16, 2024
1 parent c32c1fc commit 43bd81e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion diracx-routers/src/diracx/routers/pilot_logging/remote_logger.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from __future__ import annotations

from pydantic import BaseModel
from sqlalchemy import select

from diracx.db.sql.pilot_agents.schema import PilotAgents
from diracx.db.sql.utils import BaseSQLDB

from ..dependencies import PilotLogsDB
from ..fastapi_classes import DiracxRouter
Expand Down Expand Up @@ -30,7 +34,17 @@ async def send_message(
logger.warning(f"Message received '{data}'")
await check_permissions(action=ActionType.CREATE, pilot_db=pilot_logs_db)

Check warning on line 35 in diracx-routers/src/diracx/routers/pilot_logging/remote_logger.py

View check run for this annotation

Codecov / codecov/patch

diracx-routers/src/diracx/routers/pilot_logging/remote_logger.py#L34-L35

Added lines #L34 - L35 were not covered by tests

pilot_id = 1234 # need to get pilot id from pilot_stamp (via pilot DB)
pilot_id = 0 # need to get pilot id from pilot_stamp (via PilotAgentsDB)
piloAgentsDB = BaseSQLDB.available_implementations("PilotAgentsDB")[0]
url = BaseSQLDB.available_urls()["PilotAgentsDB"]
db = piloAgentsDB(url)

Check warning on line 40 in diracx-routers/src/diracx/routers/pilot_logging/remote_logger.py

View check run for this annotation

Codecov / codecov/patch

diracx-routers/src/diracx/routers/pilot_logging/remote_logger.py#L37-L40

Added lines #L37 - L40 were not covered by tests

async with db.engine_context():
async with db:
stmt = select(

Check warning on line 44 in diracx-routers/src/diracx/routers/pilot_logging/remote_logger.py

View check run for this annotation

Codecov / codecov/patch

diracx-routers/src/diracx/routers/pilot_logging/remote_logger.py#L42-L44

Added lines #L42 - L44 were not covered by tests
(PilotAgents.PilotID).where(PilotAgents.PilotStamp == data.pilot_stamp)
)
pilot_id = (await db.conn.execute(stmt)).scalar_one()

Check warning on line 47 in diracx-routers/src/diracx/routers/pilot_logging/remote_logger.py

View check run for this annotation

Codecov / codecov/patch

diracx-routers/src/diracx/routers/pilot_logging/remote_logger.py#L47

Added line #L47 was not covered by tests

docs = []
for line in data.lines:
Expand Down

0 comments on commit 43bd81e

Please sign in to comment.