FridgeRadar runs a small suite of recurring background jobs to keep pantry data fresh without requiring any user action. These jobs are powered by APScheduler (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/EstefanoARG/FridgeRadar/llms.txt
Use this file to discover all available pages before exploring further.
AsyncIOScheduler), which runs inside the FastAPI process and shares its async event loop. Three task modules handle distinct concerns: recalculating the freshness semáforo for every inventory item, generating expiry alert notifications, and automatically logging expired items as waste events. All tasks use CronTrigger schedules and run in the America/Lima timezone by default.
Scheduler overview
Semáforo recalculation
Runs at 00:05 daily. Recalculates
estado_caducidad for every inventory item across all households.Expiry alerts
Runs at 08:00 daily. Generates individual and bulk expiry-warning notifications for items in
amarillo, rojo, and vencido states.Auto waste logging
Runs at 02:00 daily. Automatically creates waste event records for any inventory item whose
estado_caducidad is "vencido" and has not already been logged.Task 1 — Semáforo recalculation (semaforo_task.py)
This task recalculates the estado_caducidad colour state for every product in inventory, then generates expiry alerts at 8 AM. Both jobs live in the same module and share a single AsyncIOScheduler instance:
| Job | Cron | What it does |
|---|---|---|
actualizar_semaforos | 00:05 daily | Updates estado_caducidad on all inventory rows |
generar_alertas_diarias | 08:00 daily | Creates expiry-warning notifications via SemaforoService |
Task 2 — Alert batch generation (alerta_task.py)
A second scheduler module uses AlertaService to perform a bulk alert sweep every morning. This complements the semáforo-based alerts with any additional notification logic encapsulated in AlertaService:
Task 3 — Automatic waste logging (desperdicio_task.py)
At 02:00 every morning, this task scans the inventory for items whose estado_caducidad is "vencido" and, for each one that has not yet been linked to a waste event, creates a Desperdicio record automatically:
Task schedule at a glance
| Time (default TZ) | Task | Module |
|---|---|---|
00:05 | Recalculate all semáforo states | semaforo_task.py |
02:00 | Auto-log expired items as waste | desperdicio_task.py |
08:00 | Generate expiry alerts (semaforo) | semaforo_task.py |
08:00 | Generate expiry alerts (batch) | alerta_task.py |
Timezone configuration
All three schedulers are initialised withtimezone="America/Lima" hardcoded in their respective task modules. The application settings (config.py) expose a SCHEDULER_TIMEZONE field (defaulting to "America/Lima") that can be set via the environment or .env file, but the current task modules do not read that setting — they each instantiate their own AsyncIOScheduler with the timezone literal. To change the timezone you must update the timezone= argument in each task file directly.
The timezone setting affects when the cron jobs fire in wall-clock time. If your server runs on UTC, a job scheduled for
08:00 in America/Lima (UTC−5) will actually execute at 13:00 UTC.