Skip to content

Commit 7f460c7

Browse files
committed
Align health score Python/TS: 3-component, sigmoid gating, overreaching fix
1 parent 504af77 commit 7f460c7

File tree

7 files changed

+263
-97
lines changed

7 files changed

+263
-97
lines changed

frontend/src/features/dashboard/StatisticsPage.tsx

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
type DataQuality,
2828
type BaselineMetrics,
2929
} from "../../lib/health-metrics";
30+
import { toLocalDayDate } from "../../lib/health/date";
3031
import { PROVIDER_CONFIGS } from "../../lib/providers";
3132
import {
3233
METRIC_REGISTRY,
@@ -604,14 +605,14 @@ export function StatisticsPage() {
604605
<div>
605606
<CardTitle>Health Status Score</CardTitle>
606607
<CardDescription>
607-
Composite score based on recovery core (70%) + behavior support
608-
(30%)
608+
Composite: recovery core (60%) + training load (20%) + behavior
609+
(20%)
609610
</CardDescription>
610611
</div>
611612
</div>
612613
</CardHeader>
613614
<CardContent>
614-
<div className="grid gap-6 md:grid-cols-3">
615+
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-4">
615616
<div className="text-center">
616617
<p className="text-sm text-muted-foreground mb-1">Overall</p>
617618
<p
@@ -651,6 +652,26 @@ export function StatisticsPage() {
651652
HRV + RHR + Sleep + Stress
652653
</p>
653654
</div>
655+
<div className="text-center">
656+
<p className="text-sm text-muted-foreground mb-1">
657+
Training Load
658+
</p>
659+
<p
660+
className={cn(
661+
"text-3xl font-bold",
662+
healthScore.trainingLoad !== null
663+
? getHealthScoreColor(healthScore.trainingLoad)
664+
: "text-muted-foreground",
665+
)}
666+
>
667+
{healthScore.trainingLoad !== null
668+
? healthScore.trainingLoad.toFixed(2)
669+
: "—"}
670+
</p>
671+
<p className="text-xs text-muted-foreground mt-1">
672+
Strain optimality
673+
</p>
674+
</div>
654675
<div className="text-center">
655676
<p className="text-sm text-muted-foreground mb-1">
656677
Behavior Support
@@ -666,7 +687,7 @@ export function StatisticsPage() {
666687
: "—"}
667688
</p>
668689
<p className="text-xs text-muted-foreground mt-1">
669-
Steps + Load Balance
690+
Steps + Calories + Weight
670691
</p>
671692
</div>
672693
</div>
@@ -716,6 +737,11 @@ export function StatisticsPage() {
716737
>
717738
conf: {(c.confidence * 100).toFixed(0)}%
718739
</p>
740+
{c.longTermPercentile !== null && (
741+
<p className="text-[10px] text-muted-foreground/50">
742+
P{c.longTermPercentile.toFixed(0)} all-time
743+
</p>
744+
)}
719745
{c.isGated && (
720746
<p className="text-[10px] text-red-400">{c.gateReason}</p>
721747
)}
@@ -2160,6 +2186,20 @@ export function StatisticsPage() {
21602186
<div className="flex justify-between items-center">
21612187
<span className="text-sm text-muted-foreground">
21622188
Actual
2189+
{advancedInsights.cross_domain.hrv_residual
2190+
.actual_date && (
2191+
<span className="text-[10px] ml-1 text-muted-foreground/60">
2192+
(
2193+
{toLocalDayDate(
2194+
advancedInsights.cross_domain.hrv_residual
2195+
.actual_date,
2196+
).toLocaleDateString("en-US", {
2197+
month: "short",
2198+
day: "numeric",
2199+
})}
2200+
)
2201+
</span>
2202+
)}
21632203
</span>
21642204
<span className="font-mono text-sm">
21652205
{advancedInsights.cross_domain.hrv_residual.actual?.toFixed(

0 commit comments

Comments
 (0)