SCRAPE-13: Create node-cron job initialization #18

Merged
stephen merged 1 commits from scraper/cron-job into dev 2026-02-06 17:28:54 -07:00
Owner

Summary

Implements the cron scheduler initialization for the scraper job module, completing the job orchestration layer.

Changes

  • jobs/scraperJob.js: Added initializeScheduler() and stopScheduler() functions along with status helpers getScheduleExpression() and getNextScheduledRun()
  • tests/scraper/scraperJob.test.js: Added comprehensive test suite covering all scheduler functionality

Key Features

  • Config-driven enable/disable: Respects SCRAPER_ENABLED environment variable
  • Cron expression validation with fallback to default schedule (0 6 * * *)
  • Minimum 1-hour interval enforcement to prevent excessive scraping
  • Timezone support via SCRAPER_TIMEZONE (defaults to America/Chicago)
  • Mutex integration preventing concurrent runs with guaranteed lock release
  • Status helpers for schedule expression and next run time

Test Coverage

  • 42 tests total (23 new scheduler tests + 19 existing mutex tests)
  • Covers mutex locking, scheduler lifecycle, cron validation, interval enforcement, concurrent execution prevention, error handling
## Summary Implements the cron scheduler initialization for the scraper job module, completing the job orchestration layer. ### Changes - jobs/scraperJob.js: Added initializeScheduler() and stopScheduler() functions along with status helpers getScheduleExpression() and getNextScheduledRun() - __tests__/scraper/scraperJob.test.js: Added comprehensive test suite covering all scheduler functionality ### Key Features - Config-driven enable/disable: Respects SCRAPER_ENABLED environment variable - Cron expression validation with fallback to default schedule (0 6 * * *) - Minimum 1-hour interval enforcement to prevent excessive scraping - Timezone support via SCRAPER_TIMEZONE (defaults to America/Chicago) - Mutex integration preventing concurrent runs with guaranteed lock release - Status helpers for schedule expression and next run time ### Test Coverage - 42 tests total (23 new scheduler tests + 19 existing mutex tests) - Covers mutex locking, scheduler lifecycle, cron validation, interval enforcement, concurrent execution prevention, error handling
stephen added 1 commit 2026-02-06 16:35:35 -07:00
feat: add cron scheduler initialization with validation and mutex integration
All checks were successful
CI/CD Pipeline - Apartment API / Send Webhook Notification (pull_request) Successful in 2s
CI/CD Pipeline - Apartment API / Build & Push Image (pull_request) Has been skipped
CI/CD Pipeline - Apartment API / Deploy to Production (pull_request) Has been skipped
CI/CD Pipeline - Apartment API / Scan Dependencies (pull_request) Successful in 13s
CI/CD Pipeline - Apartment API / Lint & Test (pull_request) Successful in 38s
b0163d94fb
Implement initializeScheduler() and stopScheduler() functions for the
scraper cron job module. Key features:

- Config-driven enable/disable via SCRAPER_ENABLED environment variable
- Cron expression validation with fallback to default schedule (0 6 * * *)
- Minimum interval enforcement (1-hour floor) to prevent excessive runs
- Timezone support via SCRAPER_TIMEZONE configuration
- Mutex lock integration to prevent concurrent scraper executions
- Automatic lock release in finally block for error resilience
- getScheduleExpression() and getNextScheduledRun() status helpers

Add comprehensive test suite with 42 tests covering mutex locking,
scheduler lifecycle, cron validation, minimum interval enforcement,
concurrent execution prevention, and error handling.
stephen merged commit 9d789d38fd into dev 2026-02-06 17:28:54 -07:00
stephen deleted branch scraper/cron-job 2026-02-06 17:28:54 -07:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: stephen/apartment-dashboard-api#18
No description provided.