refactor: remove cron scheduler in favor of pg-boss#355
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR completes the backend’s migration from the legacy in-process cron scheduler to pg-boss, and updates configuration/docs/UI to reflect rate-based job scheduling and the new /api/config contract.
Changes:
- Removed the Nest cron scheduler module/service and cron-based scheduling helpers/tests in favor of pg-boss-driven scheduling.
- Made job rates configurable via per-hour env vars and exposed these rates via
/api/config(updating the web UI/types accordingly). - Updated operational documentation and example configs to reflect the new scheduling model and removed env vars.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| kustomize/overlays/local/backend-configmap-local.yaml | Updates local env config to rate-based scheduling (pg-boss) variables. |
| docs/jobs.md | Removes references to DEALBOT_JOBS_MODE/cron mode and updates wording for pg-boss-only jobs. |
| docs/infra.md | Updates infra guidance for pg-boss-only scheduling and suggested run-mode separation. |
| docs/environment-variables.md | Removes legacy interval/offset vars; documents rate-based scheduling; updates quick reference. |
| apps/web/src/types/config.ts | Updates config DTO type to match new /api/config contract (jobs.* rates). |
| apps/web/src/components/Home/Config/InfrastructureInfo.tsx | Displays per-hour rates (formatted) instead of interval durations. |
| apps/backend/src/scheduler/scheduler.service.ts | Removes legacy cron scheduler service (deleted). |
| apps/backend/src/scheduler/scheduler.module.ts | Removes legacy scheduler module (deleted). |
| apps/backend/src/metrics/services/metrics-scheduler.service.ts | Removes cron setup/@Cron usage; leaves methods to be invoked by pg-boss jobs. |
| apps/backend/src/jobs/jobs.service.ts | Removes “pg-boss enabled” mode gate; enforces required per-hour rates when computing intervals. |
| apps/backend/src/jobs/jobs.service.spec.ts | Updates tests to remove legacy scheduling config/mode assumptions. |
| apps/backend/src/config/app.config.ts | Removes DEALBOT_JOBS_MODE, legacy interval/offset vars; requires per-hour job rate env vars. |
| apps/backend/src/common/utils.ts | Removes cron scheduling helpers. |
| apps/backend/src/common/utils.spec.ts | Removes tests for deleted cron helper; retains withTimeout tests. |
| apps/backend/src/app.module.ts | Stops importing legacy SchedulerModule. |
| apps/backend/src/app.controller.ts | Updates /api/config response shape to jobs.* rates. |
| apps/backend/README.md | Updates backend docs to pg-boss-only scheduling and new env vars. |
| apps/backend/.env.example | Updates example env vars for pg-boss-only scheduling (removes old scheduler mode/intervals). |
Comments suppressed due to low confidence (1)
apps/backend/src/common/utils.spec.ts:6
- The
cronmodule mock is now unused after removing the cron scheduling helpers/tests. Consider deleting thisvi.mock("cron", ...)block to reduce unnecessary dependency coupling and test noise.
// Mock the CronJob constructor - must use function syntax for constructor
vi.mock("cron", () => ({
// biome-ignore lint/complexity/useArrowFunction: Constructor requires function syntax for 'new' operator
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
SgtPooki
requested changes
Mar 16, 2026
Collaborator
SgtPooki
left a comment
There was a problem hiding this comment.
only one thing needs fixing, otherwise this looks good
SgtPooki
approved these changes
Mar 17, 2026
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.
Another step towards #271
Summary
This PR completes the migration from the legacy in-process cron scheduler to pg-boss for all job scheduling in dealbot. The cron-based scheduler has been fully removed, making pg-boss the exclusive scheduling mechanism.
Breaking Changes
The following env variables are removed (or will be ignored if set):
DEALBOT_JOBS_MODEDEAL_INTERVAL_SECONDSRETRIEVAL_INTERVAL_SECONDSDEAL_START_OFFSET_SECONDSRETRIEVAL_START_OFFSET_SECONDSMETRICS_START_OFFSET_SECONDSEnvironment Variables
The following env vars are now set with defaults (previously optional):
METRICS_PER_HOURDEALS_PER_SP_PER_HOURRETRIEVALS_PER_SP_PER_HOURDATASET_CREATIONS_PER_SP_PER_HOURAPI Contract
The
/api/configendpoint response structure has changed:scheduling.dealIntervalSeconds,scheduling.retrievalIntervalSecondsjobs.dealsPerSpPerHour,jobs.retrievalsPerSpPerHour,jobs.dataSetCreationsPerSpPerHour