# Jobs history

# Jobs history

Every background job Drillmark runs writes one row per execution to the jobs history. The Jobs page in the SPA renders it with pagination and a per-status filter.

## What shows up

The four scheduled jobs:

- **Incoming queue**: fetches new emails from every enabled data source and processes them end-to-end.
- **Failed queue**: reattempts emails sitting in the failed folder.
- **Geolocation**: enriches ingested records with country / region / city data.
- **Alerts**: evaluates alert detectors and dispatches to enabled channels.

Plus the optional weekly scheduled report (`WEEKLY_REPORT_ENABLED=true`) when configured.

## Row contents

- Started at, finished at, duration.
- Job kind.
- Data source (for incoming-queue and failed-queue runs).
- Status (`success`, `failure`, `partial`, `running`).
- Row counts: emails fetched, emails processed, parse failures, duplicates, records inserted.
- Error summary when the job failed.

Click a row to see the full per-email log for that run.

## Filters and pagination

- Status filter: narrow to runs of one status.
- Pagination at 50 rows per page.

Sort order is always started-at descending; the backend does not support a different ordering today.

## Manual trigger

Admins can kick any job manually from the Admin screen's Scheduler tab. A manual trigger writes a jobs row the same way a scheduled run does, so you can tell them apart by the timestamp but not by the row shape.

## Lock behaviour

Each scheduled job holds a row in `job_locks`. A running job refreshes `heartbeat_at` every 5 minutes; a lock with no heartbeat for 15 minutes is reaped with a warning. This is the recovery path after a crashed api process: the next scheduled fire reclaims the lock cleanly.

## Retention

The jobs history grows one row per run forever. There is no automatic retention sweep today. If storage pressure is a concern, see [Operations: Retention](/docs/drillmark/operations/retention).
