fix: add cloudonix CDR handling (#140)

* feat: add cloudonix cdr

* fix: remove org check

---------

Co-authored-by: Sabiha Khan <sabihak89@gmail.com>
This commit is contained in:
Abhishek 2026-01-29 19:06:52 +05:30 committed by GitHub
parent 91911769b0
commit b1c982a52e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 179 additions and 10 deletions

View file

@ -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()