mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 23:52:24 +00:00
chore(release): v1.28.21 — sleep history heals itself; plateau context; sync diagnostics
A one-time background pass re-reads each connected account's Google Health sleep history so nights stored twice before the sleep fix collapse to their true total (new sleep_repaired_at marker, migration 0238; watermark-safe, enqueued once at boot per un-repaired connection). The sleep night read reports when two writers disagree about the same night — the served total is unchanged, the disagreement rides along as an annotation (sourceDiscrepancy on the night DTO) so clients can mark the number instead of silently picking a side. A GLP-1 medication whose weight has plateaued on the current dose says so next to the estimated drug level (efficacy tab + insights) — a factual note from the existing detector, association only, verb-guard covered. Google Health diagnostics: the sync log now separates a daily-totals read that returned nothing from one the importer could not parse (googleHealth.rollup.emptyResponse vs droppedAll), and the connection test's structure probe reports the raw response envelope key names when a rollup type parses to zero — a per-account naming drift becomes visible from one report.
This commit is contained in:
1 parent
49be6851ec
commit
1212ed91d5
34 files changed
+1256
-7
No files matched your search
@@ -244,6 +244,11 @@ const EXEMPT_ROUTES: ReadonlyArray<string> = [
|
||||
// inventory / side-effect events), and medications is a core, always-on
|
||||
// domain with no module gate. It is not an insights-module surface.
|
||||
"src/app/api/insights/glp1-timeline/route.ts",
|
||||
// GLP-1 weight-plateau read backing the plateau note beside the drug-level
|
||||
// curve (efficacy tab + /insights/medications) — the same MEDICATIONS-domain
|
||||
// rationale as glp1-timeline above: a deterministic detector over weight +
|
||||
// dose history, no AI narrative, medications is core/always-on.
|
||||
"src/app/api/insights/glp1-plateau/route.ts",
|
||||
];
|
||||
|
||||
const MODULE_GATE_NEEDLE = "requireModuleEnabled(";
|
||||
|
||||
@@ -88,6 +88,9 @@ const NOT_COACH_OWNED_ROUTES: ReadonlyArray<string> = [
|
||||
// ability to dispose of stale recommendations.
|
||||
"src/app/api/insights/feedback/route.ts",
|
||||
"src/app/api/insights/glp1-timeline/route.ts",
|
||||
// Deterministic GLP-1 plateau detector read (no assistant prose) — same
|
||||
// medications-domain posture as glp1-timeline directly above.
|
||||
"src/app/api/insights/glp1-plateau/route.ts",
|
||||
// v1.5.5 — per-user tile layout for the `/insights` surface. The
|
||||
// endpoint persists tile visibility + ordering only; it carries no
|
||||
// assistant prose and is the mirror of `/api/dashboard/widgets`,
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* v1.28.21 — GLP-1 weight-plateau read endpoint.
|
||||
*
|
||||
* Surfaces the existing server-side plateau detector
|
||||
* (`detectGlp1Plateau`, v1.4.25) to the UI: until now the context only
|
||||
* fed the insight-generation prompt. The two GLP-1 curve surfaces (the
|
||||
* medication detail "Wirkung" tab and /insights/medications) render a
|
||||
* compact association-only note from this read. `plateau` is `null`
|
||||
* whenever the detector bows out (no active GLP-1 medication, < 21 days
|
||||
* on the current dose, weight still dropping, or fewer than two
|
||||
* readings), and the note hides cleanly. Mirrors the sibling
|
||||
* `/api/insights/glp1-timeline` read: per-user, cheap, no module gate
|
||||
* beyond auth. Auth via cookie or Bearer.
|
||||
*/
|
||||
|
||||
import { apiHandler, requireAuth } from "@/lib/api-handler";
|
||||
import { apiSuccess } from "@/lib/api-response";
|
||||
import { annotate } from "@/lib/logging/context";
|
||||
import {
|
||||
detectGlp1Plateau,
|
||||
PLATEAU_WINDOW_DAYS,
|
||||
} from "@/lib/insights/glp1-plateau";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export const GET = apiHandler(async () => {
|
||||
const { user } = await requireAuth();
|
||||
|
||||
const plateau = await detectGlp1Plateau(user.id);
|
||||
|
||||
annotate({
|
||||
action: { name: "insights.glp1-plateau.read" },
|
||||
meta: { detected: plateau !== null },
|
||||
});
|
||||
|
||||
return apiSuccess({ plateau, windowDays: PLATEAU_WINDOW_DAYS });
|
||||
});
|
||||
@@ -115,6 +115,7 @@ async function runStructureProbe(
|
||||
try {
|
||||
let points: Record<string, unknown>[];
|
||||
let requestShape: string | undefined;
|
||||
let envelopeKeys: string[] | undefined;
|
||||
if (dataType.timeField === "rollup") {
|
||||
// One minimal dailyRollUp exercise per rollup type (7-day range) — the
|
||||
// probe reports the response skeleton AND which documented request
|
||||
@@ -130,6 +131,13 @@ async function runStructureProbe(
|
||||
onShape: (shape) => {
|
||||
requestShape = shape;
|
||||
},
|
||||
// Raw envelope key names of the first page (names only). When the
|
||||
// parse yields zero points this is the one signal that separates
|
||||
// "the service returned nothing" from "the service returned points
|
||||
// under a key this reader does not know" — per-cohort naming drift.
|
||||
onEnvelopeKeys: (keys) => {
|
||||
envelopeKeys = keys;
|
||||
},
|
||||
},
|
||||
);
|
||||
} else {
|
||||
@@ -155,6 +163,9 @@ async function runStructureProbe(
|
||||
count: points.length,
|
||||
structure: points.length > 0 ? describeStructure(points[0]) : null,
|
||||
...(requestShape ? { requestShape } : {}),
|
||||
// Only meaningful when the parse came back empty — a populated parse
|
||||
// proves the envelope key already matches.
|
||||
...(points.length === 0 && envelopeKeys ? { envelopeKeys } : {}),
|
||||
};
|
||||
} catch (e) {
|
||||
results[name] =
|
||||
|
||||
@@ -88,6 +88,19 @@ function serializeSession(s: SleepSession) {
|
||||
end: seg.end.toISOString(),
|
||||
minutes: Math.round(seg.minutes),
|
||||
})),
|
||||
// Additive, observational: two writer buckets reported clearly
|
||||
// different asleep totals for this session. Never changes the served
|
||||
// totals above — the UI only marks the number with a discreet hint.
|
||||
sourceDiscrepancy: s.sourceDiscrepancy
|
||||
? {
|
||||
deltaMinutes: Math.round(s.sourceDiscrepancy.deltaMinutes),
|
||||
sources: s.sourceDiscrepancy.sources.map((b) => ({
|
||||
source: b.source,
|
||||
deviceType: b.deviceType,
|
||||
asleepMinutes: Math.round(b.asleepMinutes),
|
||||
})),
|
||||
}
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user