Optimize get_workflow_scripts_by_cache_key_value SQL (#4095)
This commit is contained in:
committed by
GitHub
parent
f00e82c1bb
commit
43be44cce5
@@ -945,7 +945,7 @@ async def _regenerate_script_block_after_ai_fallback(
|
||||
if not cache_key_value:
|
||||
cache_key_value = cache_key # Fallback
|
||||
|
||||
existing_scripts = await app.DATABASE.get_workflow_scripts_by_cache_key_value(
|
||||
existing_script = await app.DATABASE.get_workflow_script_by_cache_key_value(
|
||||
organization_id=organization_id,
|
||||
workflow_permanent_id=workflow.workflow_permanent_id,
|
||||
cache_key_value=cache_key_value,
|
||||
@@ -953,11 +953,11 @@ async def _regenerate_script_block_after_ai_fallback(
|
||||
statuses=[ScriptStatus.published],
|
||||
)
|
||||
|
||||
if not existing_scripts:
|
||||
if not existing_script:
|
||||
LOG.error("No existing script found to regenerate", cache_key=cache_key, cache_key_value=cache_key_value)
|
||||
return
|
||||
|
||||
current_script = existing_scripts[0]
|
||||
current_script = existing_script
|
||||
LOG.info(
|
||||
"Regenerating script block after AI fallback",
|
||||
script_id=current_script.script_id,
|
||||
|
||||
@@ -76,22 +76,21 @@ async def get_workflow_script(
|
||||
return None, rendered_cache_key_value
|
||||
|
||||
# Check if there are existing cached scripts for this workflow + cache_key_value
|
||||
existing_scripts = await app.DATABASE.get_workflow_scripts_by_cache_key_value(
|
||||
existing_script = await app.DATABASE.get_workflow_script_by_cache_key_value(
|
||||
organization_id=workflow.organization_id,
|
||||
workflow_permanent_id=workflow.workflow_permanent_id,
|
||||
cache_key_value=rendered_cache_key_value,
|
||||
statuses=[status],
|
||||
)
|
||||
|
||||
if existing_scripts:
|
||||
if existing_script:
|
||||
LOG.info(
|
||||
"Found cached script for workflow",
|
||||
workflow_id=workflow.workflow_id,
|
||||
cache_key_value=rendered_cache_key_value,
|
||||
workflow_run_id=workflow_run.workflow_run_id,
|
||||
script_count=len(existing_scripts),
|
||||
)
|
||||
return existing_scripts[0], rendered_cache_key_value
|
||||
return existing_script, rendered_cache_key_value
|
||||
|
||||
return None, rendered_cache_key_value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user