mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-19 08:12:52 +00:00
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:
1 parent
05b5eb6942
commit
367fcd5332
12 files changed
+497
-129
No files matched your search
@@ -22,6 +22,7 @@ import {
|
||||
import {
|
||||
insightsCardsResponse,
|
||||
insightsComprehensiveResponse,
|
||||
insightsPresenceResponse,
|
||||
metricStatusQuery,
|
||||
metricStatusResponse,
|
||||
biomarkerAssessmentQuery,
|
||||
@@ -126,6 +127,29 @@ export const insightsPaths: NonNullable<ZodOpenApiObject["paths"]> = {
|
||||
},
|
||||
},
|
||||
},
|
||||
"/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: dataEnvelope(
|
||||
insightsPresenceResponse,
|
||||
"InsightsPresenceEnvelope",
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
...stdResponses,
|
||||
...recordRefusal(),
|
||||
},
|
||||
},
|
||||
},
|
||||
"/api/insights/cards": {
|
||||
get: {
|
||||
tags: ["Insights"],
|
||||
|
||||
@@ -1691,6 +1691,36 @@ export const ecgListResponse = z
|
||||
"Metadata-only ECG recording list. Never carries the waveform — the per-recording strip is fetched on demand from GET /api/insights/ecg/{id}. Read-only; no LLM call. Reflects only the device's own classification, never a HealthLog interpretation.",
|
||||
});
|
||||
|
||||
export const insightsPresenceResponse = z
|
||||
.object({
|
||||
metrics: z
|
||||
.record(z.string(), z.object({ count: z.number().int() }))
|
||||
.describe(
|
||||
"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: z
|
||||
.boolean()
|
||||
.describe(
|
||||
"A mood entry in the last 90 days. False while the mood module is off.",
|
||||
),
|
||||
hasMedication: z
|
||||
.boolean()
|
||||
.describe(
|
||||
"An active medication with a schedule whose intake is tracked. False while the medications module is off.",
|
||||
),
|
||||
hasWorkouts: z
|
||||
.boolean()
|
||||
.describe(
|
||||
"At least one workout. False while the workouts module is off.",
|
||||
),
|
||||
hasEcgRecordings: z.boolean().describe("At least one ECG recording."),
|
||||
})
|
||||
.meta({
|
||||
id: "InsightsPresence",
|
||||
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.",
|
||||
});
|
||||
|
||||
export const ecgDetailQuery = z
|
||||
.object({
|
||||
full: z
|
||||
|
||||
Reference in new issue
Block a user