Class: ReportScheduleService
Defined in: server/insights/scheduling/report-schedule-service.ts:138
The request-path orchestrator for scheduled deliveries. Its whole reason to
exist is to keep TWO stores in lockstep: the saved_report_schedules row
(the durable record) and the BullMQ job scheduler in Redis (what actually
fires). Every write goes through here so the two never drift:
- create commits the desired row before registering the scheduler. If
registration fails (a
customcron BullMQ rejects), the row is rolled back only when no newer mutation has superseded it. - update rewrites the row, then re-registers the scheduler. If the new config can't register it ROLLS THE CONFIG BACK to the last-known-good one (the schedule keeps delivering on its old pattern) rather than pausing — never silently kill a healthy schedule on a bad edit or a Redis blip.
- setEnabled flips the row, then re-syncs: enabled → upsert; disabled → remove. Enabling a schedule whose config can't register fails closed (it stays disabled) — you can't enable a broken schedule.
- delete soft-deletes the row, then removes the scheduler.
The row is always committed FIRST (it is the source of truth). Redis calls never occupy a database transaction or make uncommitted state observable. Every mutation increments a durable version copied into BullMQ job data; stale writers re-read and apply the newer desired state, while stale fires skip delivery. Cross-store atomicity is impossible (Redis + PG), so reconcileReportSchedules also closes the crash window between the committed row and its Redis synchronization at worker startup.
Constructors
Constructor
new ReportScheduleService(deps: ReportScheduleServiceDeps): ReportScheduleService;Defined in: server/insights/scheduling/report-schedule-service.ts:141
Parameters
| Parameter | Type |
|---|---|
deps | ReportScheduleServiceDeps |
Returns
ReportScheduleService
Methods
create()
create(input: CreateReportScheduleInput, ctx: ReportScheduleContext): Promise<ReportSchedule>;Defined in: server/insights/scheduling/report-schedule-service.ts:200
Parameters
| Parameter | Type |
|---|---|
input | CreateReportScheduleInput |
ctx | ReportScheduleContext |
Returns
Promise<ReportSchedule>
createDashboard()
createDashboard(input: CreateDashboardScheduleInput, ctx: ReportScheduleContext): Promise<DashboardSchedule>;Defined in: server/insights/scheduling/report-schedule-service.ts:227
Parameters
| Parameter | Type |
|---|---|
input | CreateDashboardScheduleInput |
ctx | ReportScheduleContext |
Returns
Promise<DashboardSchedule>
delete()
delete(id: string, ctx: ReportScheduleContext): Promise<void>;Defined in: server/insights/scheduling/report-schedule-service.ts:534
Parameters
| Parameter | Type |
|---|---|
id | string |
ctx | ReportScheduleContext |
Returns
Promise<void>
get()
get(id: string, ctx: ReportScheduleContext): Promise<ReportSchedule>;Defined in: server/insights/scheduling/report-schedule-service.ts:180
Parameters
| Parameter | Type |
|---|---|
id | string |
ctx | ReportScheduleContext |
Returns
Promise<ReportSchedule>
getDashboardScheduleManagement()
getDashboardScheduleManagement(dashboardKey: string, ctx: ReportScheduleContext): Promise<DashboardScheduleManagementState>;Defined in: server/insights/scheduling/report-schedule-service.ts:254
Parameters
| Parameter | Type |
|---|---|
dashboardKey | string |
ctx | ReportScheduleContext |
Returns
Promise<DashboardScheduleManagementState>
list()
list(ctx: ReportScheduleContext, savedReportId?: string): Promise<ReportSchedule[]>;Defined in: server/insights/scheduling/report-schedule-service.ts:148
Parameters
| Parameter | Type |
|---|---|
ctx | ReportScheduleContext |
savedReportId? | string |
Returns
Promise<ReportSchedule[]>
listRuns()
listRuns(id: string, ctx: ReportScheduleContext): Promise<InsightScheduleRunSummary[]>;Defined in: server/insights/scheduling/report-schedule-service.ts:189
Parameters
| Parameter | Type |
|---|---|
id | string |
ctx | ReportScheduleContext |
Returns
Promise<InsightScheduleRunSummary[]>
runNow()
runNow(input: RunReportScheduleNowInput, ctx: ReportScheduleContext): Promise<RunReportScheduleNowResult>;Defined in: server/insights/scheduling/report-schedule-service.ts:563
Enqueue one delivery without changing recurring state. Disabled schedules may be run deliberately; deletion, tenant scoping, write authorization, corrupt config, and concurrent mutations all fail closed before send.
Parameters
| Parameter | Type |
|---|---|
input | RunReportScheduleNowInput |
ctx | ReportScheduleContext |
Returns
Promise<RunReportScheduleNowResult>
setEnabled()
setEnabled(
id: string,
enabled: boolean,
ctx: ReportScheduleContext
): Promise<void>;Defined in: server/insights/scheduling/report-schedule-service.ts:461
Parameters
| Parameter | Type |
|---|---|
id | string |
enabled | boolean |
ctx | ReportScheduleContext |
Returns
Promise<void>
update()
update(
id: string,
input: UpdateReportScheduleInput,
ctx: ReportScheduleContext
): Promise<ReportSchedule>;Defined in: server/insights/scheduling/report-schedule-service.ts:348
Parameters
| Parameter | Type |
|---|---|
id | string |
input | UpdateReportScheduleInput |
ctx | ReportScheduleContext |
Returns
Promise<ReportSchedule>
updateDashboard()
updateDashboard(
id: string,
input: UpdateReportScheduleInput,
ctx: ReportScheduleContext
): Promise<DashboardSchedule>;Defined in: server/insights/scheduling/report-schedule-service.ts:372
Parameters
| Parameter | Type |
|---|---|
id | string |
input | UpdateReportScheduleInput |
ctx | ReportScheduleContext |
Returns
Promise<DashboardSchedule>