From 9c42931c9e94308fbae54af3d1f26b006ce4cf17 Mon Sep 17 00:00:00 2001 From: Christophe Vila Date: Fri, 17 Jul 2026 19:06:01 +0200 Subject: [PATCH] fix: restore standard HR zone defaults, relax zone-boundary validation instead of migration --- backend/internal/api/profile.go | 6 ------ .../internal/store/migrations/0003_profile.sql | 18 +++++++++--------- backend/internal/store/profile_test.go | 4 ++-- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/backend/internal/api/profile.go b/backend/internal/api/profile.go index 318d7da..a5c61a8 100644 --- a/backend/internal/api/profile.go +++ b/backend/internal/api/profile.go @@ -19,12 +19,6 @@ func validateProfile(p store.Profile) error { {p.HRZone4MinPct, p.HRZone4MaxPct}, {p.HRZone5MinPct, p.HRZone5MaxPct}, } - if zones[0][0] != 0 { - return errors.New("zone 1 must start at 0%") - } - if zones[len(zones)-1][1] != 100 { - return errors.New("zone 5 must end at 100%") - } for i, z := range zones { if z[0] >= z[1] { return errors.New("each HR zone's min must be less than its max") diff --git a/backend/internal/store/migrations/0003_profile.sql b/backend/internal/store/migrations/0003_profile.sql index 743a587..b30798a 100644 --- a/backend/internal/store/migrations/0003_profile.sql +++ b/backend/internal/store/migrations/0003_profile.sql @@ -7,15 +7,15 @@ CREATE TABLE profile ( rolling_window_days INTEGER NOT NULL DEFAULT 90, max_heart_rate REAL, resting_heart_rate REAL, - hr_zone1_min_pct REAL NOT NULL DEFAULT 0, - hr_zone1_max_pct REAL NOT NULL DEFAULT 20, - hr_zone2_min_pct REAL NOT NULL DEFAULT 20, - hr_zone2_max_pct REAL NOT NULL DEFAULT 40, - hr_zone3_min_pct REAL NOT NULL DEFAULT 40, - hr_zone3_max_pct REAL NOT NULL DEFAULT 60, - hr_zone4_min_pct REAL NOT NULL DEFAULT 60, - hr_zone4_max_pct REAL NOT NULL DEFAULT 80, - hr_zone5_min_pct REAL NOT NULL DEFAULT 80, + hr_zone1_min_pct REAL NOT NULL DEFAULT 50, + hr_zone1_max_pct REAL NOT NULL DEFAULT 60, + hr_zone2_min_pct REAL NOT NULL DEFAULT 60, + hr_zone2_max_pct REAL NOT NULL DEFAULT 70, + hr_zone3_min_pct REAL NOT NULL DEFAULT 70, + hr_zone3_max_pct REAL NOT NULL DEFAULT 80, + hr_zone4_min_pct REAL NOT NULL DEFAULT 80, + hr_zone4_max_pct REAL NOT NULL DEFAULT 90, + hr_zone5_min_pct REAL NOT NULL DEFAULT 90, hr_zone5_max_pct REAL NOT NULL DEFAULT 100, easy_warmup_minutes REAL NOT NULL DEFAULT 10, easy_cooldown_minutes REAL NOT NULL DEFAULT 5, diff --git a/backend/internal/store/profile_test.go b/backend/internal/store/profile_test.go index 360ac3b..cd2f171 100644 --- a/backend/internal/store/profile_test.go +++ b/backend/internal/store/profile_test.go @@ -16,8 +16,8 @@ func TestProfile_DefaultsThenUpdate(t *testing.T) { if p.RollingWindowDays != 90 { t.Errorf("RollingWindowDays = %d, want 90 (migration default)", p.RollingWindowDays) } - if p.HRZone1MinPct != 0 || p.HRZone5MaxPct != 100 { - t.Errorf("zone defaults = %+v, want Z1 min=0, Z5 max=100", p) + if p.HRZone1MinPct != 50 || p.HRZone5MaxPct != 100 { + t.Errorf("zone defaults = %+v, want Z1 min=50, Z5 max=100", p) } maxHR, restingHR := 190.0, 50.0