|
|
|
|
@ -7,6 +7,7 @@ from celery import shared_task # type: ignore
|
|
|
|
|
from sqlalchemy import delete
|
|
|
|
|
from sqlalchemy.exc import SQLAlchemyError
|
|
|
|
|
|
|
|
|
|
from core.repository import RepositoryFactory
|
|
|
|
|
from extensions.ext_database import db
|
|
|
|
|
from models.dataset import AppDatasetJoin
|
|
|
|
|
from models.model import (
|
|
|
|
|
@ -30,7 +31,7 @@ from models.model import (
|
|
|
|
|
)
|
|
|
|
|
from models.tools import WorkflowToolProvider
|
|
|
|
|
from models.web import PinnedConversation, SavedMessage
|
|
|
|
|
from models.workflow import ConversationVariable, Workflow, WorkflowAppLog, WorkflowNodeExecution, WorkflowRun
|
|
|
|
|
from models.workflow import ConversationVariable, Workflow, WorkflowAppLog, WorkflowRun
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@shared_task(queue="app_deletion", bind=True, max_retries=3)
|
|
|
|
|
@ -187,18 +188,20 @@ def _delete_app_workflow_runs(tenant_id: str, app_id: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _delete_app_workflow_node_executions(tenant_id: str, app_id: str):
|
|
|
|
|
def del_workflow_node_execution(workflow_node_execution_id: str):
|
|
|
|
|
db.session.query(WorkflowNodeExecution).filter(WorkflowNodeExecution.id == workflow_node_execution_id).delete(
|
|
|
|
|
synchronize_session=False
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
_delete_records(
|
|
|
|
|
"""select id from workflow_node_executions where tenant_id=:tenant_id and app_id=:app_id limit 1000""",
|
|
|
|
|
{"tenant_id": tenant_id, "app_id": app_id},
|
|
|
|
|
del_workflow_node_execution,
|
|
|
|
|
"workflow node execution",
|
|
|
|
|
# Create a repository instance for WorkflowNodeExecution
|
|
|
|
|
repository = RepositoryFactory.create_workflow_node_execution_repository(
|
|
|
|
|
params={
|
|
|
|
|
"tenant_id": tenant_id,
|
|
|
|
|
"app_id": app_id,
|
|
|
|
|
"session_factory": db.session.get_bind,
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Use the clear method to delete all records for this tenant_id and app_id
|
|
|
|
|
repository.clear()
|
|
|
|
|
|
|
|
|
|
logging.info(click.style(f"Deleted workflow node executions for tenant {tenant_id} and app {app_id}", fg="green"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _delete_app_workflow_app_logs(tenant_id: str, app_id: str):
|
|
|
|
|
def del_workflow_app_log(workflow_app_log_id: str):
|
|
|
|
|
|