Add pump profile fetching and Insulineprofiel page
willemjan/glucose-dashboard/pipeline/head This commit looks good
willemjan/glucose-dashboard/pipeline/head This commit looks good
Fetch and parse the latest-used Nightscout profile (basal schedule, ISF, carb ratio, DIA, targets) and show it as a new dashboard page: a list of basal/ISF/carb-ratio segments plus a bar chart of basal rate by hour of day. This is the data foundation for treatment overlays on the glucose charts and the redesigned PDF report in follow-up PRs.
This commit is contained in:
@@ -252,3 +252,21 @@ def fetch_treatments_range(start_date: date, end_date: date) -> pd.DataFrame:
|
||||
since = datetime.combine(start_date, time.min, tzinfo=timezone.utc)
|
||||
until = datetime.combine(end_date, time.max, tzinfo=timezone.utc)
|
||||
return _treatments_since(since, until)
|
||||
|
||||
|
||||
def fetch_profile() -> dict:
|
||||
"""Haal het meest recent gebruikte pompprofiel op.
|
||||
|
||||
Nightscout's /api/v1/profile.json geeft profieldocumenten terug, nieuwste
|
||||
eerst; met count=1 krijgen we alleen het actief gebruikte document. Een
|
||||
profiel is geen tijdreeks (in tegenstelling tot entries/treatments) dus
|
||||
geen paginering nodig — één klein verzoek volstaat.
|
||||
|
||||
Geeft {} terug als er geen profiel bestaat (bijv. lege Nightscout-instantie).
|
||||
Het resultaat is het rauwe Nightscout-documument; zie profile_data.parse_profile()
|
||||
voor de genormaliseerde vorm (basaalschema, ISF, koolhydraatratio, DIA, streefwaarden).
|
||||
"""
|
||||
data = _get("/api/v1/profile.json", {"count": 1})
|
||||
if not data:
|
||||
return {}
|
||||
return data[0]
|
||||
|
||||
Reference in New Issue
Block a user