Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions apps/sim/app/api/workflows/[id]/deploy/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
}
})
Expand Down
13 changes: 8 additions & 5 deletions apps/sim/app/api/workflows/[id]/status/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
}
})
Expand Down
27 changes: 27 additions & 0 deletions apps/sim/lib/workflows/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down