willemjan 29d20ca441 fix: Nightscout API silently truncated multi-day fetches to ~3-4 days
_entries_since/_treatments_since requested a single page via `count`,
but Nightscout's /api/v1/entries and /api/v1/treatments ignore a large
`count` and cap the response around ~1150/~700 documents regardless of
how far back the requested period goes. Every report page relying on
fetch_entries_range/fetch_treatments_range (7/14/30/90-day selectors)
was silently only getting the most recent ~3-4 days, no matter the
selected period.

Fixed by paginating with `find[date][$lte]` cursors in a new
_paginated_get(), walking back until the requested `since` boundary is
reached or the server returns a short/empty page (= genuinely no more
data, confirmed by manually paginating against the real instance:
entries go back 50+ days, treatments only ~4 days on this install).

Also added reporting.completeness_warning(), shared by the interactive
pages (via ui_common.render_completeness_warning) and the PDF export,
that distinguishes "a structural gap at the start of the period" (data
wasn't fetched/available) from "scattered gaps below the clinical AGP
coverage threshold" (Danne et al. 2017) — the previous single generic
"X% sensor coverage" message read as a CGM/sensor problem even when
the real cause was this fetch bug.
2026-07-31 14:21:35 +02:00
2026-07-24 07:49:59 +02:00
2026-07-26 21:10:46 +02:00
2026-07-24 07:49:59 +02:00

glucose-dashboard

Dashboard van glucosedata, live opgehaald uit een Nightscout-instantie. Meerdere pagina's (zie zijbalk): een rollend live-overzicht en een set klinische rapportagepagina's (zie docs/requirements-reporting.md en docs/design-reporting.md).

Instellen

  1. Zorg voor een draaiende Nightscout-instantie en een API-token (Admin Tools

    Manage Tokens in Nightscout — geef het token minimaal readable-rechten) of het klassieke API secret.

  2. Kopieer .env.example naar .env en vul NIGHTSCOUT_URL, één van de twee auth-opties, en DASHBOARD_PASSWORD_HASH in (zie het voorbeeldbestand voor hoe je die hash genereert — de dashboard-URL wordt gedeeld met het diabetesteam, dus elke pagina zit achter een wachtwoord). app.py laadt .env zelf in (via python-dotenv), dus dit werkt hetzelfde onder PowerShell, cmd of bash — je hoeft de variabelen niet zelf in je shell te zetten.

  3. Lokaal draaien:

    uv venv
    uv pip install -r requirements.txt --python .venv
    .venv\Scripts\streamlit run app.py
    
  4. Met Docker Compose:

    docker compose up -d
    

    docker-compose.yml leest .env via env_file — dat bestand wordt niet meegecommit (zie .gitignore).

Tests en lint

pytest tests/ -v
ruff check .
S
Description
dashboard van glucose data
Readme
322 KiB
Languages
Python 99.8%
Dockerfile 0.2%