mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-22 08:38:13 +02:00
feat: add cloudonix cdr
This commit is contained in:
parent
91911769b0
commit
07558ec785
6 changed files with 211 additions and 10 deletions
|
|
@ -468,3 +468,30 @@ class WorkflowRunClient(BaseDBClient):
|
|||
)
|
||||
)
|
||||
return result.scalars().first()
|
||||
|
||||
async def get_workflow_run_by_call_id(
|
||||
self, call_id: str
|
||||
) -> Optional[WorkflowRunModel]:
|
||||
"""Find workflow run by call_id stored in gathered_context.
|
||||
|
||||
Args:
|
||||
call_id: The telephony call ID to search for
|
||||
|
||||
Returns:
|
||||
The WorkflowRunModel if found, None otherwise
|
||||
"""
|
||||
async with self.async_session() as session:
|
||||
# Use JSON text extraction to find matching call_id
|
||||
# This leverages the idx_workflow_runs_call_id index
|
||||
result = await session.execute(
|
||||
select(WorkflowRunModel)
|
||||
.options(
|
||||
joinedload(WorkflowRunModel.workflow).joinedload(WorkflowModel.user)
|
||||
)
|
||||
.where(
|
||||
WorkflowRunModel.gathered_context.op("->>")("call_id") == call_id
|
||||
)
|
||||
.order_by(WorkflowRunModel.created_at.desc())
|
||||
.limit(1)
|
||||
)
|
||||
return result.scalars().first()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue