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

Method materializeJobs

apps/sim/lib/copilot/vfs/workspace-vfs.ts:1970–2072  ·  view source on GitHub ↗

* Materialize scheduled jobs using the workflowSchedule table. * Returns a summary for WORKSPACE.md generation.

(
    workspaceId: string
  )

Source from the content-addressed store, hash-verified

1968 * Returns a summary for WORKSPACE.md generation.
1969 */
1970 private async materializeJobs(
1971 workspaceId: string
1972 ): Promise<NonNullable<WorkspaceMdData['jobs']>> {
1973 try {
1974 const jobRows = await db
1975 .select({
1976 id: workflowSchedule.id,
1977 jobTitle: workflowSchedule.jobTitle,
1978 prompt: workflowSchedule.prompt,
1979 cronExpression: workflowSchedule.cronExpression,
1980 timezone: workflowSchedule.timezone,
1981 status: workflowSchedule.status,
1982 lifecycle: workflowSchedule.lifecycle,
1983 successCondition: workflowSchedule.successCondition,
1984 maxRuns: workflowSchedule.maxRuns,
1985 runCount: workflowSchedule.runCount,
1986 nextRunAt: workflowSchedule.nextRunAt,
1987 lastRanAt: workflowSchedule.lastRanAt,
1988 sourceTaskName: workflowSchedule.sourceTaskName,
1989 sourceChatId: workflowSchedule.sourceChatId,
1990 jobHistory: workflowSchedule.jobHistory,
1991 createdAt: workflowSchedule.createdAt,
1992 })
1993 .from(workflowSchedule)
1994 .where(
1995 and(
1996 eq(workflowSchedule.sourceWorkspaceId, workspaceId),
1997 eq(workflowSchedule.sourceType, 'job'),
1998 isNull(workflowSchedule.archivedAt),
1999 ne(workflowSchedule.status, 'completed')
2000 )
2001 )
2002
2003 for (const job of jobRows) {
2004 const safeName = sanitizeName(job.jobTitle || job.id)
2005 this.files.set(
2006 `jobs/${safeName}/meta.json`,
2007 serializeJobMeta({
2008 id: job.id,
2009 title: job.jobTitle,
2010 prompt: job.prompt || '',
2011 cronExpression: job.cronExpression,
2012 timezone: job.timezone,
2013 status: job.status,
2014 lifecycle: job.lifecycle,
2015 successCondition: job.successCondition,
2016 maxRuns: job.maxRuns,
2017 runCount: job.runCount,
2018 nextRunAt: job.nextRunAt,
2019 lastRanAt: job.lastRanAt,
2020 sourceTaskName: job.sourceTaskName,
2021 sourceChatId: job.sourceChatId,
2022 createdAt: job.createdAt,
2023 })
2024 )
2025
2026 const history = job.jobHistory as Array<{ timestamp: string; summary: string }> | null
2027 if (history && history.length > 0) {

Callers 1

materializeMethod · 0.95

Calls 8

registerLazyMethod · 0.95
serializeJobMetaFunction · 0.90
toErrorFunction · 0.90
sanitizeNameFunction · 0.70
setMethod · 0.65
warnMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected