feat(api): check for recording status
This commit is contained in:
parent
cdc92d1a52
commit
ee1c433f6f
2 changed files with 26 additions and 3 deletions
|
|
@ -1109,7 +1109,7 @@ def session_exists(project_id, session_id):
|
|||
return row is not None
|
||||
|
||||
|
||||
def check_recording_status(project_id: int) -> bool:
|
||||
def check_recording_status(project_id: int) -> dict:
|
||||
query = f"""
|
||||
WITH project_sessions AS (
|
||||
SELECT * FROM public.sessions WHERE project_id = %(project_id)s
|
||||
|
|
@ -1124,7 +1124,9 @@ def check_recording_status(project_id: int) -> bool:
|
|||
(SELECT COUNT(*) FROM sessions_with_duration) = 0 THEN 1
|
||||
WHEN (SELECT COUNT(*) FROM project_sessions) > 0 AND
|
||||
(SELECT COUNT(*) FROM sessions_with_duration) > 0 THEN 2
|
||||
END AS recording_status;
|
||||
END AS recording_status,
|
||||
COUNT(*) AS sessions_count
|
||||
FROM project_sessions;
|
||||
"""
|
||||
|
||||
with pg_client.PostgresClient() as cur:
|
||||
|
|
@ -1132,5 +1134,9 @@ def check_recording_status(project_id: int) -> bool:
|
|||
cur.execute(query)
|
||||
row = cur.fetchone()
|
||||
|
||||
return row["recording_status"]
|
||||
return {
|
||||
"recording_status": row["recording_status"],
|
||||
"sessions_count": row["sessions_count"]
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -844,6 +844,23 @@ async def delete_msteams_integration(webhookId: int, _=Body(None),
|
|||
|
||||
@app.get('/{project_id}/check-recording-status', tags=["sessions"])
|
||||
async def check_recording_status(project_id: int):
|
||||
"""
|
||||
Check the recording status and sessions count for a given project ID.
|
||||
|
||||
Args:
|
||||
project_id (int): The ID of the project to check.
|
||||
|
||||
Returns:
|
||||
dict: A dictionary containing the recording status and sessions count.
|
||||
The dictionary has the following structure:
|
||||
{
|
||||
"recording_status": int, # The recording status:
|
||||
# 0 - No sessions
|
||||
# 1 - Processing
|
||||
# 2 - Ready
|
||||
"sessions_count": int # The total count of sessions
|
||||
}
|
||||
"""
|
||||
return {"data": sessions.check_recording_status(project_id=project_id)}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue