Skip to content

app.routers.data_status

data_status

Data freshness / provenance — surfaces what was last ingested for each source.

get_data_status async

get_data_status(request: Request, response: Response)

Per-source ingestion + data freshness from the provenance table.

Returns one row per (table, source) with the latest data timestamp, when it was last ingested, the resulting lag in hours, and a status bucket (fresh / warn / stale) so the UI can colour-code at a glance.

Provenance comes from a sister table the upstream BirdCurve NL pipeline populates after each ingestion run; previously the dashboard ignored it.

Source code in dashboard/backend/app/routers/data_status.py
@router.get("")
async def get_data_status(request: Request, response: Response):
    """Per-source ingestion + data freshness from the provenance table.

    Returns one row per (table, source) with the latest data timestamp,
    when it was last ingested, the resulting lag in hours, and a status
    bucket (fresh / warn / stale) so the UI can colour-code at a glance.

    Provenance comes from a sister table the upstream BirdCurve NL pipeline
    populates after each ingestion run; previously the dashboard ignored it.
    """
    engine = request.app.state.engine
    payload = await run_in_threadpool(_data_status_sync, engine)
    response.headers["Cache-Control"] = "public, max-age=300"
    return payload