fix(insights): gate the tab strip on one presence read

The tab strip on every Insights page read the whole overview (22 KB),
a workouts page, the ECG list and the analytics summaries to learn which
pills to show. GET /api/insights/presence answers just that, for the
record on screen: the reading count per type after the record's module
switches, and whether it has mood entries in the last 90 days, a tracked
scheduled medication, workouts and ECG recordings. A flag whose page a
switched-off module hides is false and its rows are not read. The strip
now reads this and the saved layout; each page keeps loading its own data.
This commit is contained in:
Marc-André Bombeck committed 2026-11-12 12:56:16 +01:00
1 parent 05b5eb6942
commit 367fcd5332
12 files changed
+497 -129

No files matched your search

+79
View File
@@ -13115,6 +13115,27 @@ paths:
"403": *a20
"422": *a4
"429": *a5
/api/insights/presence:
get:
tags:
- Insights
summary: Which Insights pages have data
description: "What the Insights tab strip gates its pills on, for the record on screen: the reading count per
measurement type (after the record's module switches) and whether the record has mood entries in the last 90
days, a tracked scheduled medication, workouts and ECG recordings. A flag whose module is off is false. Counts
and flags only; each page reads its own data. No provider is called and no AI switch refuses it. Delegable at
MANAGE level over the whole record. Cookie or Bearer auth."
responses:
"200":
description: The presence answer.
content:
application/json:
schema:
$ref: "#/components/schemas/InsightsPresenceEnvelope"
"401": *a1
"403": *a20
"422": *a4
"429": *a5
/api/insights/cards:
get:
tags:
@@ -34933,6 +34954,7 @@ components:
- BLOOD_PRESSURE_SYS
- PULSE
- BLOOD_GLUCOSE
- BLOOD_KETONES
- OXYGEN_SATURATION
- BODY_TEMPERATURE
- BODY_FAT
@@ -68518,6 +68540,63 @@ components:
additionalProperties: false
description: A significant Pearson correlation (n >= 20, p < 0.05). The field holding it is null when the pairing is not
significant.
InsightsPresenceEnvelope:
type: object
properties:
data:
$ref: "#/components/schemas/InsightsPresence"
error:
type: "null"
meta:
type: object
properties:
requestId:
type: string
additionalProperties: false
required:
- data
- error
additionalProperties: false
InsightsPresence:
type: object
properties:
metrics:
type: object
propertyNames:
type: string
additionalProperties:
type: object
properties:
count:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
required:
- count
additionalProperties: false
description: "Keyed by `MeasurementType`: the reading count of every type with at least one reading, after the record's
module switches. The same counts `GET /api/analytics?slice=summaries` reports."
hasMood:
type: boolean
description: A mood entry in the last 90 days. False while the mood module is off.
hasMedication:
type: boolean
description: An active medication with a schedule whose intake is tracked. False while the medications module is off.
hasWorkouts:
type: boolean
description: At least one workout. False while the workouts module is off.
hasEcgRecordings:
type: boolean
description: At least one ECG recording.
required:
- metrics
- hasMood
- hasMedication
- hasWorkouts
- hasEcgRecordings
additionalProperties: false
description: "Which Insights pages have something to show for the record: what the tab strip gates its pills on. Counts
and flags only, no values."
InsightsCardsEnvelope:
type: object
properties: