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

Function applyScheduleUpdate

apps/sim/background/schedule-execution.ts:134–162  ·  view source on GitHub ↗
(
  scheduleId: string,
  updates: WorkflowScheduleUpdate,
  requestId: string,
  context: string,
  options: { expectedLastQueuedAt?: Date | null } = {}
)

Source from the content-addressed store, hash-verified

132}
133
134async function applyScheduleUpdate(
135 scheduleId: string,
136 updates: WorkflowScheduleUpdate,
137 requestId: string,
138 context: string,
139 options: { expectedLastQueuedAt?: Date | null } = {}
140): Promise<boolean> {
141 try {
142 const claimGuard =
143 options.expectedLastQueuedAt === undefined
144 ? undefined
145 : options.expectedLastQueuedAt === null
146 ? isNull(workflowSchedule.lastQueuedAt)
147 : eq(workflowSchedule.lastQueuedAt, options.expectedLastQueuedAt)
148
149 const updatedRows = await db
150 .update(workflowSchedule)
151 .set(updates)
152 .where(
153 and(eq(workflowSchedule.id, scheduleId), isNull(workflowSchedule.archivedAt), claimGuard)
154 )
155 .returning({ id: workflowSchedule.id })
156
157 return updatedRows.length > 0
158 } catch (error) {
159 logger.error(`[${requestId}] ${context}`, error, { cause: describeError(error) })
160 throw error
161 }
162}
163
164export async function releaseScheduleLock(
165 scheduleId: string,

Callers 4

releaseScheduleLockFunction · 0.85
updateClaimedScheduleFunction · 0.85
executeJobInlineFunction · 0.85

Calls 4

describeErrorFunction · 0.90
errorMethod · 0.80
setMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected