MCPcopy Index your code
hub / github.com/simstudioai/sim / createSchedulesIfStillActive

Function createSchedulesIfStillActive

apps/sim/lib/workflows/deployment-outbox.ts:576–620  ·  view source on GitHub ↗
(params: {
  workflowId: string
  deploymentVersionId: string
  blocks: Record<string, BlockState>
})

Source from the content-addressed store, hash-verified

574}
575
576async function createSchedulesIfStillActive(params: {
577 workflowId: string
578 deploymentVersionId: string
579 blocks: Record<string, BlockState>
580}) {
581 return db.transaction(async (tx) => {
582 const [workflowRecord] = await tx
583 .select({ id: workflowTable.id })
584 .from(workflowTable)
585 .where(eq(workflowTable.id, params.workflowId))
586 .limit(1)
587 .for('update')
588
589 if (!workflowRecord) {
590 return { success: true as const }
591 }
592
593 const [versionRow] = await tx
594 .select({ id: workflowDeploymentVersion.id })
595 .from(workflowDeploymentVersion)
596 .where(
597 and(
598 eq(workflowDeploymentVersion.workflowId, params.workflowId),
599 eq(workflowDeploymentVersion.id, params.deploymentVersionId),
600 eq(workflowDeploymentVersion.isActive, true)
601 )
602 )
603 .limit(1)
604
605 if (!versionRow) {
606 return { success: true as const }
607 }
608
609 const result = await createSchedulesForDeploy(
610 params.workflowId,
611 params.blocks,
612 tx,
613 params.deploymentVersionId
614 )
615 if (!result.success) {
616 throw new Error(result.error || 'Failed to sync schedules')
617 }
618 return result
619 })
620}
621
622async function pruneWorkflowGroupOutputsIfStillActive(params: {
623 workflowId: string

Callers 1

syncActiveSideEffectsFunction · 0.85

Calls 2

createSchedulesForDeployFunction · 0.90
eqFunction · 0.50

Tested by

no test coverage detected