1
0
Fork 0
mirror of synced 2024-07-06 23:10:57 +12:00

add new status to handle no iterations during loop

This commit is contained in:
Peter Clement 2023-03-31 12:20:47 +01:00
parent 9a02364856
commit 0a567a3302
3 changed files with 18 additions and 5 deletions

View file

@ -58,7 +58,7 @@
/>
{#if openBlocks[block.id]}
<Divider noMargin />
{#if filteredResults?.[idx]?.outputs.iterations}
{#if filteredResults?.[idx]?.outputs?.iterations}
<div style="display: flex; padding: 10px 10px 0px 12px;">
<Icon name="Reuse" />
<div style="margin-left: 10px;">

View file

@ -34,8 +34,8 @@ const STOPPED_STATUS = { success: true, status: AutomationStatus.STOPPED }
function getLoopIterations(loopStep: LoopStep, input: LoopInput) {
const binding = automationUtils.typecastForLooping(loopStep, input)
if (!loopStep || !binding) {
return 1
if (!binding) {
return 0
}
if (Array.isArray(binding)) {
return binding.length
@ -43,7 +43,7 @@ function getLoopIterations(loopStep: LoopStep, input: LoopInput) {
if (typeof binding === "string") {
return automationUtils.stringSplit(binding).length
}
return 1
return 0
}
/**
@ -423,13 +423,25 @@ class Orchestrator {
}
}
if (loopStep && iterations === 0) {
loopStep = undefined
this.executionOutput.steps.splice(loopStepNumber + 1, 0, {
id: step.id,
stepId: step.stepId,
outputs: { status: AutomationStatus.NO_ITERATIONS, success: true },
inputs: {},
})
this._context.steps.splice(loopStepNumber, 1)
iterations = 1
}
// Delete the step after the loop step as it's irrelevant, since information is included
// in the loop step
if (wasLoopStep && !loopStep) {
this._context.steps.splice(loopStepNumber + 1, 1)
wasLoopStep = false
}
if (loopSteps && loopSteps.length) {
let tempOutput = {
success: true,

View file

@ -83,6 +83,7 @@ export enum AutomationStatus {
ERROR = "error",
STOPPED = "stopped",
STOPPED_ERROR = "stopped_error",
NO_ITERATIONS = "no_iterations",
}
export interface AutomationResults {