fix not logging when user accessed they files and only show the file access from the user files and not all
Build and Push Docker Container / build-and-push (push) Successful in 1m37s
Build and Push Docker Container / build-and-push (push) Successful in 1m37s
This commit is contained in:
@@ -276,6 +276,40 @@ class EdgeDB:
|
||||
"accessed_at": file.at,
|
||||
} for file in data]
|
||||
|
||||
async def get_all_access_of_user(self, user_id:str):
|
||||
data = await self.run_query_with_reconnection(
|
||||
self.client.query,
|
||||
"""
|
||||
select files {
|
||||
file_id,
|
||||
file_name,
|
||||
note,
|
||||
accesses: {
|
||||
at,
|
||||
status,
|
||||
ip: {
|
||||
value
|
||||
},
|
||||
user_agent: {
|
||||
value
|
||||
}
|
||||
}
|
||||
order by .at desc
|
||||
}
|
||||
filter .user_id = <str>$user_id
|
||||
""",
|
||||
user_id=user_id
|
||||
)
|
||||
return sorted([{
|
||||
"file_id": file.file_id,
|
||||
"file_name": file.file_name,
|
||||
"file_note": file.note,
|
||||
"status": access.status,
|
||||
"ip": access.ip.value,
|
||||
"user_agent": access.user_agent.value,
|
||||
"accessed_at": access.at,
|
||||
} for file in data for access in file.accesses], key=lambda x: x["accessed_at"], reverse=True)
|
||||
|
||||
async def get_file_access(self, file_id: str):
|
||||
data = await self.run_query_with_reconnection(
|
||||
self.client.query_single,
|
||||
|
||||
Reference in New Issue
Block a user