Workflow query optimization (#4330)

This commit is contained in:
LawyZheng
2025-12-19 02:54:09 +08:00
committed by GitHub
parent 8ebe0f2bfb
commit 6ee3d7e620
5 changed files with 27 additions and 4 deletions

View File

@@ -626,9 +626,14 @@ class BaseTaskBlock(Block):
workflow_run_id=workflow_run_id,
organization_id=organization_id,
)
workflow = await app.WORKFLOW_SERVICE.get_workflow_by_permanent_id(
workflow_permanent_id=workflow_run.workflow_permanent_id,
)
# Get workflow from context if available, otherwise query database
workflow = workflow_run_context.workflow
if workflow is None:
workflow = await app.WORKFLOW_SERVICE.get_workflow_by_permanent_id(
workflow_permanent_id=workflow_run.workflow_permanent_id,
)
# Cache the workflow back to context for future block executions
workflow_run_context.set_workflow(workflow)
# if the task url is parameterized, we need to get the value from the workflow run context
if self.url and workflow_run_context.has_parameter(self.url) and workflow_run_context.has_value(self.url):
task_url_parameter_value = workflow_run_context.get_value(self.url)