MCPcopy
hub / github.com/nowork-studio/NotFair / createScheduledJob

Function createScheduledJob

notfair-cmo/src/server/scheduler/index.ts:47–79  ·  view source on GitHub ↗
(input: CreateScheduledJobInput)

Source from the content-addressed store, hash-verified

45}
46
47export function createScheduledJob(input: CreateScheduledJobInput): ScheduledJob {
48 const db = getDb();
49 const now = new Date().toISOString();
50 const next_run_at = input.enabled === false ? null : computeNextRun(input.cron_expr);
51 const job: ScheduledJob = {
52 id: randomUUID(),
53 project_slug: input.project_slug,
54 agent_id: input.agent_id,
55 name: input.name,
56 cron_expr: input.cron_expr,
57 message: input.message,
58 enabled: input.enabled === false ? 0 : 1,
59 last_run_at: null,
60 next_run_at,
61 created_at: now,
62 updated_at: now,
63 };
64 db.prepare(
65 "INSERT INTO scheduled_jobs (id, project_slug, agent_id, name, cron_expr, message, enabled, last_run_at, next_run_at, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?)",
66 ).run(
67 job.id,
68 job.project_slug,
69 job.agent_id,
70 job.name,
71 job.cron_expr,
72 job.message,
73 job.enabled,
74 job.next_run_at,
75 job.created_at,
76 job.updated_at,
77 );
78 return job;
79}
80
81export function getScheduledJob(id: string): ScheduledJob | null {
82 return (

Callers 3

createCronFunction · 0.90
cloneAgentFunction · 0.90

Calls 2

getDbFunction · 0.90
computeNextRunFunction · 0.85

Tested by

no test coverage detected