Skip to Content
⚠️Active Development Notice: TimeTiles is under active development. Information may be placeholder content or not up-to-date.

Background Jobs

TimeTiles uses Payload CMS’s built-in job queue for all asynchronous processing. Jobs are defined in lib/jobs/ and registered in lib/config/payload-shared-config.ts.

Key Behavior

  • Auto-deletion: Completed jobs are automatically deleted (deleteJobOnComplete: true)
  • Hook-driven queueing: Jobs are queued by collection afterChange hooks via StageTransitionService, not manually
  • Single process: Jobs run in the same Node.js process as the web server (no separate worker)

Import Pipeline Jobs

These 8 jobs process files through the import pipeline sequentially. See Data Processing Pipeline for detailed stage documentation.

JobPurposeTrigger
dataset-detectionParse file, create import jobs per sheetFile upload to import-files
analyze-duplicatesFind internal/external duplicate rowsStage transition
schema-detectionBuild progressive JSON Schema from dataStage transition
validate-schemaCompare detected vs existing schemaStage transition
create-schema-versionPersist approved schema versionApproval or auto-approve
geocode-batchGeocode unique locations via providersStage transition
create-events-batchCreate event records in databaseStage transition

Scheduled Import Jobs

JobPurposeTrigger
schedule-managerCheck cron schedules, trigger due importsPeriodic (runs on interval)
url-fetchDownload file from URL for scheduled importSchedule manager
cleanup-stuck-scheduled-importsReset imports stuck in processing statePeriodic
process-pending-retriesRetry failed imports with exponential backoffPeriodic
cleanup-approval-locksRelease stale approval locksPeriodic

System Maintenance Jobs

JobPurposeTrigger
quota-resetReset daily user quota counters (midnight UTC)Periodic
cache-cleanupClean expired cache entriesPeriodic
schema-maintenanceClean up orphaned schema versionsPeriodic
audit-log-ip-cleanupClear IP addresses older than 30 days (privacy)Periodic
data-exportGenerate ZIP archive of user dataUser request
data-export-cleanupDelete expired export filesPeriodic
execute-account-deletionProcess scheduled account deletions after grace periodPeriodic

Adding a New Job

  1. Create handler in lib/jobs/handlers/my-job.ts
  2. Export job config from lib/jobs/import-jobs.ts
  3. Add to ALL_JOBS array in lib/config/payload-shared-config.ts
  4. Create migration if the job needs new fields

Testing Jobs

See Integration Testing Patterns for job testing. Key points:

  • Query pending jobs before running (completedAt: { exists: false })
  • Verify side effects after running (not job records — they’re deleted)
  • Use describe.sequential() for tests that interact with the job queue
Last updated on