mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 23:17:59 -05:00
fix(subflows): added change detection for parallels, updated deploy and status schemas to match parallel/loop (#956)
This commit is contained in:
@@ -211,16 +211,19 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
|
||||
const config = (subflow.config as any) || {}
|
||||
if (subflow.type === 'loop') {
|
||||
loops[subflow.id] = {
|
||||
id: subflow.id,
|
||||
nodes: config.nodes || [],
|
||||
iterationCount: config.iterationCount || 1,
|
||||
iterationType: config.iterationType || 'fixed',
|
||||
collection: config.collection || '',
|
||||
iterations: config.iterations || 1,
|
||||
loopType: config.loopType || 'for',
|
||||
forEachItems: config.forEachItems || '',
|
||||
}
|
||||
} else if (subflow.type === 'parallel') {
|
||||
parallels[subflow.id] = {
|
||||
id: subflow.id,
|
||||
nodes: config.nodes || [],
|
||||
parallelCount: config.parallelCount || 2,
|
||||
collection: config.collection || '',
|
||||
count: config.count || 2,
|
||||
distribution: config.distribution || '',
|
||||
parallelType: config.parallelType || 'count',
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -57,16 +57,19 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
|
||||
const config = (subflow.config as any) || {}
|
||||
if (subflow.type === 'loop') {
|
||||
loops[subflow.id] = {
|
||||
id: subflow.id,
|
||||
nodes: config.nodes || [],
|
||||
iterationCount: config.iterationCount || 1,
|
||||
iterationType: config.iterationType || 'fixed',
|
||||
collection: config.collection || '',
|
||||
iterations: config.iterations || 1,
|
||||
loopType: config.loopType || 'for',
|
||||
forEachItems: config.forEachItems || '',
|
||||
}
|
||||
} else if (subflow.type === 'parallel') {
|
||||
parallels[subflow.id] = {
|
||||
id: subflow.id,
|
||||
nodes: config.nodes || [],
|
||||
parallelCount: config.parallelCount || 2,
|
||||
collection: config.collection || '',
|
||||
count: config.count || 2,
|
||||
distribution: config.distribution || '',
|
||||
parallelType: config.parallelType || 'count',
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -313,6 +313,33 @@ export function hasWorkflowChanged(
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Compare parallels
|
||||
const currentParallels = currentState.parallels || {}
|
||||
const deployedParallels = deployedState.parallels || {}
|
||||
|
||||
const currentParallelIds = Object.keys(currentParallels).sort()
|
||||
const deployedParallelIds = Object.keys(deployedParallels).sort()
|
||||
|
||||
if (
|
||||
currentParallelIds.length !== deployedParallelIds.length ||
|
||||
normalizedStringify(currentParallelIds) !== normalizedStringify(deployedParallelIds)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
|
||||
// Compare each parallel with normalized values
|
||||
for (const parallelId of currentParallelIds) {
|
||||
const normalizedCurrentParallel = normalizeValue(currentParallels[parallelId])
|
||||
const normalizedDeployedParallel = normalizeValue(deployedParallels[parallelId])
|
||||
|
||||
if (
|
||||
normalizedStringify(normalizedCurrentParallel) !==
|
||||
normalizedStringify(normalizedDeployedParallel)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user