Function: deliverScheduledReport()
function deliverScheduledReport(data: ReportScheduleJobData, deps: DeliverScheduledReportDeps): Promise<void>;Defined in: server/insights/scheduling/report-schedule-worker.ts:133
Deliver one scheduled or manually requested report. The pure core of the worker — exported so it is unit-testable with fakes, no Redis. For a fire it:
- loads the schedule (org-scoped);
- for recurring fires, tears down the BullMQ scheduler and skips if the row is gone or paused; a manual fire may run a paused row and never mutates its recurring scheduler;
- exports the saved report AS THE SCHEDULE'S OWNER (
created_by), so the export's owner/visibility checks see the same identity that created the schedule — a scheduled delivery can never read a report its creator could not; - hands the rendered file to EmailSender.send;
- records the run outcome on the schedule row.
A failure at export or send records a failed run and RETHROWS, so the
caller (BullMQ) applies retry/backoff. Delivery is therefore AT-LEAST-ONCE: a
send that succeeds but whose transport ack is lost re-fires and re-emails.
Once the transport accepts the email, however, recording success is
best-effort: a metadata-write failure must not trigger a duplicate delivery.
Parameters
| Parameter | Type |
|---|---|
data | ReportScheduleJobData |
deps | DeliverScheduledReportDeps |
Returns
Promise<void>