Daily Archiving Job
Overview
The auto-archiver keeps the Visual Experience Engine tidy by moving expired scheduled content from published to archived. Scheduled content that is past its schedule end dates is no longer shown to users, so archiving it reflects its true state and keeps lists manageable.
Schedule and Configuration
| Setting | Default | Description |
|---|---|---|
| Schedule | every 24 hours | How often the job runs (configurable per site) |
| Timezone | config.ianaTimezone | Used for schedule timing (e.g. America/New_York) |
| Timeout | 300 seconds | Max execution time |
| Memory | 1GiB | Function memory allocation |
| Concurrency | 1 | Only one instance runs at a time |
Configuration lives in consumer configs (e.g. configs/bildit.js, configs/belk.js) under bannersAutoArchiver.
What Gets Archived
Scheduled content is archived when all of these are true:
- Published –
published === true - Has schedules –
banner.schedulesis a non-empty array - All schedules expired – Every schedule has
endDate < now
If scheduled content has no schedules, or if any schedule still includes the current time, it is not archived.
Schedule Logic
archived = Array.isArray(banner.schedules)
&& banner.schedules.every((schedule) => now > schedule.endDate)
What the Job Does
For each app in the database:
- Fetches all published scheduled content
- Checks each scheduled content item's
schedulesarray - For scheduled content items where every schedule has expired:
- Sets
published→false - Sets
archived→true - Sets
autoArchiveTime→ current timestamp (for debugging)
- Sets
- Writes updates in chunks of 50 to stay within Firebase write limits
Manual Trigger
An HTTP-triggered version exists in banners-auto-archive.js for manual runs. It uses the same logic as the scheduled job and can be invoked via the banners_auto_archive function when you need to run archiving on demand (e.g. testing or catching up after downtime).
Related Concepts
| Concept | Reference |
|---|---|
Schedule structure (startDate, endDate, slot) | Scheduled Content Concept |
| Scheduled content states (live, scheduled, expired, archived) | Scheduled Content Concept |
| Hooks that run when scheduled content is archived | Webhooks |
Implementation
- Scheduled function:
apps/bildit-cms/functions/utility-functions/schedule-functions.js→bannersAutoArchiver - HTTP trigger:
apps/bildit-cms/functions/utility-functions/banners-auto-archive.js