For code deletion via workflow save, only ask to delete published code (not pending) (#3682)
This commit is contained in:
@@ -4510,6 +4510,8 @@ class AgentDB:
|
||||
self,
|
||||
organization_id: str,
|
||||
workflow_permanent_id: str,
|
||||
statuses: list[ScriptStatus] | None = None,
|
||||
script_ids: list[str] | None = None,
|
||||
) -> int:
|
||||
"""
|
||||
Soft delete all published workflow scripts for a workflow permanent id by setting deleted_at timestamp.
|
||||
@@ -4530,6 +4532,12 @@ class AgentDB:
|
||||
.values(deleted_at=datetime.now(timezone.utc))
|
||||
)
|
||||
|
||||
if statuses:
|
||||
stmt = stmt.where(WorkflowScriptModel.status.in_([s.value for s in statuses]))
|
||||
|
||||
if script_ids:
|
||||
stmt = stmt.where(WorkflowScriptModel.script_id.in_(script_ids))
|
||||
|
||||
result = await session.execute(stmt)
|
||||
await session.commit()
|
||||
|
||||
@@ -4545,6 +4553,7 @@ class AgentDB:
|
||||
self,
|
||||
organization_id: str,
|
||||
workflow_permanent_id: str,
|
||||
statuses: list[ScriptStatus] | None = None,
|
||||
) -> list[WorkflowScriptModel]:
|
||||
try:
|
||||
async with self.Session() as session:
|
||||
@@ -4555,6 +4564,9 @@ class AgentDB:
|
||||
.filter_by(deleted_at=None)
|
||||
)
|
||||
|
||||
if statuses:
|
||||
query = query.filter(WorkflowScriptModel.status.in_([s.value for s in statuses]))
|
||||
|
||||
return (await session.scalars(query)).all()
|
||||
except SQLAlchemyError:
|
||||
LOG.error("SQLAlchemyError", exc_info=True)
|
||||
|
||||
Reference in New Issue
Block a user