feat(reports): report schedules honor cron_expression + timezone#1991
Merged
Conversation
sys_report_schedule has long carried `cron_expression` and `timezone` fields, but ReportService only ever advanced next_run_at by `interval_minutes` — both fields were stored and ignored. Scheduling now computes next_run_at from the cron expression (when present) in the schedule's timezone via croner — the same library the job scheduler uses — so "every weekday 09:00 local" is expressible. interval_minutes remains the fallback. - cron_expression wins over interval_minutes when set (the field's documented contract); evaluated in `timezone` (default UTC). - scheduleReport validates the cron eagerly → VALIDATION_FAILED on bad input, rather than silently falling back at sweep time. A cron that becomes unschedulable later is logged and falls back to interval; it never throws into the dispatch sweep. - Shared nextRunAt() helper drives both initial schedule and advance. DB-polling dispatch model unchanged; only the next-run computation is cron-aware. Self-contained slice of ADR-0053 Phase 2 — report schedules run under a system context, so the tz source is the schedule's own field, independent of the reference-timezone resolver. Tests: cron drives/overrides interval; honors timezone (09:00 ET = 14:00Z); invalid cron rejected; dispatchDue advances to next cron occurrence. Full plugin-reports suite green (29). Closes #1983. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 2 package(s): 3 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1983. Self-contained slice of ADR-0053 Phase 2.
What
sys_report_schedulehas long carriedcron_expressionandtimezonefields, butReportServiceonly ever advancednext_run_atbyinterval_minutes— both fields were stored and ignored (author-facing but runtime-dead). This activates them.Scheduling now computes
next_run_atfrom the cron expression (when present) in the schedule's timezone, viacroner— the same library the job scheduler (CronJobAdapter) already uses. So "every weekday at 09:00 local" is finally expressible.interval_minutesremains the fallback.Behavior
cron_expressionwins overinterval_minuteswhen set (the field's documented contract).timezone(defaultUTC).scheduleReportvalidates the cron eagerly and rejects an invalid one withVALIDATION_FAILED, instead of silently degrading at sweep time. A cron that later has no next occurrence is logged and falls back to the interval — it never throws into the dispatch sweep.nextRunAt()helper drives both the initial schedule andadvanceSchedule.The DB-polling dispatch model (
next_run_at <= nowsweep) is unchanged — only the next-run computation became cron-aware. This fits report-service's architecture far better than the in-process croner-job model, and works across multi-instance deployments.Why self-contained
Report schedules run under a system context (no user), so the timezone source is the schedule's own
timezonefield — same model assys_job. So this slice needs none of the reference-timezone resolver (#1978) and can land independently.Testing
09:00 America/New_York=14:00Z); invalid cron →VALIDATION_FAILED;dispatchDueadvances to the next cron occurrence.@objectstack/plugin-reportssuite green — 29 tests; DTS build + typecheck clean.sys_report_scheduledoc comment (no longer "reserved"). Changeset:minor(new capability).🤖 Generated with Claude Code