File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
diracx-db/src/diracx/db/os
diracx-routers/src/diracx/routers/pilot_logging Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 66class PilotLogsDB (BaseOSDB ):
77 fields = {
88 "PilotStamp" : {"type" : "keyword" },
9+ "PilotID" : {"type" : "long" },
910 "LineNumber" : {"type" : "long" },
1011 "Message" : {"type" : "text" },
1112 "VO" : {"type" : "keyword" },
Original file line number Diff line number Diff line change @@ -51,10 +51,28 @@ async def send_message(
5151 docs .append (
5252 {
5353 "PilotStamp" : data .pilot_stamp ,
54+ "PilotID" : pilot_id ,
5455 "VO" : data .vo ,
5556 "LineNumber" : line .line_no ,
5657 "Message" : line .line ,
5758 }
5859 )
5960 await pilot_logs_db .bulk_insert (pilot_logs_db .index_name (pilot_id ), docs )
60- return data
61+ return pilot_id
62+
63+
64+ @router .get ("/logs" )
65+ async def get_logs (
66+ pilot_id : int ,
67+ db : PilotLogsDB ,
68+ check_permissions : CheckPilotLogsPolicyCallable ,
69+ ):
70+ logger .warning (f"Retrieving message for pilot ID '{ pilot_id } '" )
71+ await check_permissions (action = ActionType .QUERY , pilot_db = db )
72+
73+ result = await db .search (
74+ ["Message" ],
75+ [{"parameter" : "PilotID" , "operator" : "eq" } | {"value" : pilot_id }],
76+ [{"parameter" : "LineNumber" , "direction" : "asc" }],
77+ )
78+ return result
You can’t perform that action at this time.
0 commit comments