Kaizen
Browse modulesInsightsinsights/sharedFunctions

Function: reportScheduleToCron()

function reportScheduleToCron(config: 
  | {
  cadence: "daily";
  format: "pdf" | "csv" | "xlsx";
  recipients: string[];
  timeOfDay: string;
  timezone: string;
}
  | {
  cadence: "weekly";
  format: "pdf" | "csv" | "xlsx";
  recipients: string[];
  timeOfDay: string;
  timezone: string;
  weekdays: number[];
}
  | {
  cadence: "monthly";
  dayOfMonth: number | "last";
  format: "pdf" | "csv" | "xlsx";
  recipients: string[];
  timeOfDay: string;
  timezone: string;
}
  | {
  cadence: "custom";
  cron: string;
  format: "pdf" | "csv" | "xlsx";
  recipients: string[];
  timezone: string;
}): ReportScheduleCron;

Defined in: shared/insights/schedule.ts:259

Translate a validated ReportScheduleConfig into the single cron pattern + timezone BullMQ repeats on. This is the ONE place intent becomes a cron string, so the dialog's preview and the worker's firing can never diverge.

The custom branch passes its cron through untouched — BullMQ (and its cron-parser) is the authority on that string, not this function.

Parameters

ParameterType
config| { cadence: "daily"; format: "pdf" | "csv" | "xlsx"; recipients: string[]; timeOfDay: string; timezone: string; } | { cadence: "weekly"; format: "pdf" | "csv" | "xlsx"; recipients: string[]; timeOfDay: string; timezone: string; weekdays: number[]; } | { cadence: "monthly"; dayOfMonth: number | "last"; format: "pdf" | "csv" | "xlsx"; recipients: string[]; timeOfDay: string; timezone: string; } | { cadence: "custom"; cron: string; format: "pdf" | "csv" | "xlsx"; recipients: string[]; timezone: string; }

Returns

ReportScheduleCron

On this page