mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
chore(release): v1.4.27
v1.4.27 — Mobile capability and maintainer-finding cleanup. ResponsiveSheet primitive (bottom-sheet on narrow viewports, centred dialog on desktop) applied to BD, Weight, Glucose, Mood, Activity forms. Maintainer-finding cleanups across Coach, Insights, Reports, Privacy. GeoLite2 offline geocoding with resilience layer (graceful fallback when EULA not yet propagated). E2E gap-fill coverage. 450-line release notes attached to the GitHub Release.
This commit is contained in:
1 parent
d98e85cd03
commit
4f09c3f862
314 files changed
+26801
-4419
No files matched your search
@@ -305,13 +305,6 @@ export function getWeightRange(heightCm: number): { min: number; max: number } {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Normal resting pulse range (AHA).
|
||||
*/
|
||||
export function getPulseRange(): { min: number; max: number } {
|
||||
return { min: 60, max: 100 };
|
||||
}
|
||||
|
||||
/**
|
||||
* Recommended nightly sleep duration for adults (AASM/SRS).
|
||||
*/
|
||||
|
||||
@@ -104,57 +104,6 @@ export function trendSlope(
|
||||
};
|
||||
}
|
||||
|
||||
// ── Trend Line Points ────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Generate two data points representing the linear trend line endpoints.
|
||||
* Used by chart components to overlay a regression line.
|
||||
*/
|
||||
export function trendLinePoints(
|
||||
data: DataPoint[],
|
||||
windowDays: number,
|
||||
): { start: DataPoint; end: DataPoint } | null {
|
||||
if (data.length < 2) return null;
|
||||
|
||||
const sorted = [...data].sort((a, b) => a.date.getTime() - b.date.getTime());
|
||||
const cutoff =
|
||||
sorted[sorted.length - 1].date.getTime() - windowDays * 24 * 60 * 60 * 1000;
|
||||
const window = sorted.filter((p) => p.date.getTime() >= cutoff);
|
||||
|
||||
if (window.length < 2) return null;
|
||||
|
||||
const startTime = window[0].date.getTime();
|
||||
const points = window.map((p) => ({
|
||||
x: (p.date.getTime() - startTime) / (24 * 60 * 60 * 1000),
|
||||
y: p.value,
|
||||
}));
|
||||
|
||||
const n = points.length;
|
||||
const sumX = points.reduce((s, p) => s + p.x, 0);
|
||||
const sumY = points.reduce((s, p) => s + p.y, 0);
|
||||
const sumXY = points.reduce((s, p) => s + p.x * p.y, 0);
|
||||
const sumXX = points.reduce((s, p) => s + p.x * p.x, 0);
|
||||
|
||||
const denominator = n * sumXX - sumX * sumX;
|
||||
if (denominator === 0) return null;
|
||||
|
||||
const slope = (n * sumXY - sumX * sumY) / denominator;
|
||||
const intercept = (sumY - slope * sumX) / n;
|
||||
|
||||
const endDays = points[points.length - 1].x;
|
||||
|
||||
return {
|
||||
start: {
|
||||
date: window[0].date,
|
||||
value: Math.round(intercept * 100) / 100,
|
||||
},
|
||||
end: {
|
||||
date: window[window.length - 1].date,
|
||||
value: Math.round((intercept + slope * endDays) * 100) / 100,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// ── Anomaly Detection ────────────────────────────────────
|
||||
|
||||
export interface Anomaly {
|
||||
|
||||
Reference in new issue
Block a user