sequential workflow fix (#3473)
This commit is contained in:
@@ -1786,6 +1786,27 @@ class AgentDB:
|
|||||||
LOG.error("SQLAlchemyError", exc_info=True)
|
LOG.error("SQLAlchemyError", exc_info=True)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
async def get_last_running_workflow_run(
|
||||||
|
self,
|
||||||
|
workflow_permanent_id: str,
|
||||||
|
organization_id: str | None = None,
|
||||||
|
) -> WorkflowRun | None:
|
||||||
|
try:
|
||||||
|
async with self.Session() as session:
|
||||||
|
query = select(WorkflowRunModel).filter_by(workflow_permanent_id=workflow_permanent_id)
|
||||||
|
if organization_id:
|
||||||
|
query = query.filter_by(organization_id=organization_id)
|
||||||
|
query = query.filter_by(status=WorkflowRunStatus.running)
|
||||||
|
query = query.filter(
|
||||||
|
WorkflowRunModel.started_at.isnot(None)
|
||||||
|
) # filter out workflow runs that does not have a started_at timestamp
|
||||||
|
query = query.order_by(WorkflowRunModel.started_at.desc())
|
||||||
|
workflow_run = (await session.scalars(query)).first()
|
||||||
|
return convert_to_workflow_run(workflow_run) if workflow_run else None
|
||||||
|
except SQLAlchemyError:
|
||||||
|
LOG.error("SQLAlchemyError", exc_info=True)
|
||||||
|
raise
|
||||||
|
|
||||||
async def get_workflow_runs(
|
async def get_workflow_runs(
|
||||||
self,
|
self,
|
||||||
organization_id: str,
|
organization_id: str,
|
||||||
|
|||||||
Reference in New Issue
Block a user