Optimize get_workflow_scripts_by_cache_key_value SQL (#4095)

This commit is contained in:
Stanislav Novosad
2025-11-25 12:15:06 -07:00
committed by GitHub
parent f00e82c1bb
commit 43be44cce5
4 changed files with 30 additions and 85 deletions

View File

@@ -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,