2026-07-17 18:53:55 +02:00
|
|
|
package store
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"testing"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestWorkoutTypePaces_SeededOnePerKindThenUpdate(t *testing.T) {
|
|
|
|
|
db := openTestDB(t)
|
|
|
|
|
ctx := context.Background()
|
|
|
|
|
|
2026-07-25 13:44:06 +02:00
|
|
|
userID, err := db.ProvisionUser(ctx, "test-sub", "Test")
|
|
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("ProvisionUser: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
all, err := db.ListWorkoutTypePaces(ctx, userID)
|
2026-07-17 18:53:55 +02:00
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("ListWorkoutTypePaces: %v", err)
|
|
|
|
|
}
|
2026-07-19 10:52:09 +02:00
|
|
|
if len(all) != 8 {
|
|
|
|
|
t.Fatalf("expected 8 seeded pace rows (one per taxonomy kind), got %d", len(all))
|
2026-07-17 18:53:55 +02:00
|
|
|
}
|
|
|
|
|
for _, p := range all {
|
Dedup Garmin data storage, configurable chart colors, taxonomy fixes, sync/progression fixes
- Remove duplicated Garmin fields from storage; decode display-only fields
(activity name/type, lap duration/HR, structured workout raw JSON) from
RawJSON at API-response time instead of storing redundant columns
- Add a fully configurable chart color system (pace/HR main-line colors, 4
effort-kind colors, tint/darken/brighten intensity knobs) under Profile >
Chart colors
- Rename training types and fix their display order (Easy, Long, 60'/30'
Threshold, Tempo, Intervals, MAS Test, Race) everywhere they're listed
- Add an Efficiency Factor progression metric; fix Progression chart axes to
use tight non-zero-based domains, m:ss/km pace formatting, and rounded
ticks instead of raw floating-point labels
- Expose the raw get_workout_by_id() payload in the raw-data viewer
alongside activity/lap/detail JSON; enlarge the modal and shrink array
indentation for readability
- Fix "last sync" reporting a meaningless activity count: record one
combined sync run per manual "Sync now" and count genuinely new
activities instead of re-listing whatever Garmin returned for the queried
window
- Let a Review Queue activity be manually cleared back to Unclassified, and
make "Reset all" available even while disconnected from Garmin
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-20 06:33:47 +02:00
|
|
|
if p.PaceMinSecPerKm != nil || p.PaceMaxSecPerKm != nil || p.HRMinPctHRR != nil || p.HRMaxPctHRR != nil {
|
2026-07-17 18:53:55 +02:00
|
|
|
t.Errorf("expected all-nil seeded pace row for kind %d, got %+v", p.WorkoutKindID, p)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
target := all[0]
|
Dedup Garmin data storage, configurable chart colors, taxonomy fixes, sync/progression fixes
- Remove duplicated Garmin fields from storage; decode display-only fields
(activity name/type, lap duration/HR, structured workout raw JSON) from
RawJSON at API-response time instead of storing redundant columns
- Add a fully configurable chart color system (pace/HR main-line colors, 4
effort-kind colors, tint/darken/brighten intensity knobs) under Profile >
Chart colors
- Rename training types and fix their display order (Easy, Long, 60'/30'
Threshold, Tempo, Intervals, MAS Test, Race) everywhere they're listed
- Add an Efficiency Factor progression metric; fix Progression chart axes to
use tight non-zero-based domains, m:ss/km pace formatting, and rounded
ticks instead of raw floating-point labels
- Expose the raw get_workout_by_id() payload in the raw-data viewer
alongside activity/lap/detail JSON; enlarge the modal and shrink array
indentation for readability
- Fix "last sync" reporting a meaningless activity count: record one
combined sync run per manual "Sync now" and count genuinely new
activities instead of re-listing whatever Garmin returned for the queried
window
- Let a Review Queue activity be manually cleared back to Unclassified, and
make "Reset all" available even while disconnected from Garmin
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-20 06:33:47 +02:00
|
|
|
minPace, maxPace, hrMin, hrMax := 330.0, 420.0, 70.0, 80.0
|
2026-07-17 18:53:55 +02:00
|
|
|
target.PaceMinSecPerKm = &minPace
|
|
|
|
|
target.PaceMaxSecPerKm = &maxPace
|
Dedup Garmin data storage, configurable chart colors, taxonomy fixes, sync/progression fixes
- Remove duplicated Garmin fields from storage; decode display-only fields
(activity name/type, lap duration/HR, structured workout raw JSON) from
RawJSON at API-response time instead of storing redundant columns
- Add a fully configurable chart color system (pace/HR main-line colors, 4
effort-kind colors, tint/darken/brighten intensity knobs) under Profile >
Chart colors
- Rename training types and fix their display order (Easy, Long, 60'/30'
Threshold, Tempo, Intervals, MAS Test, Race) everywhere they're listed
- Add an Efficiency Factor progression metric; fix Progression chart axes to
use tight non-zero-based domains, m:ss/km pace formatting, and rounded
ticks instead of raw floating-point labels
- Expose the raw get_workout_by_id() payload in the raw-data viewer
alongside activity/lap/detail JSON; enlarge the modal and shrink array
indentation for readability
- Fix "last sync" reporting a meaningless activity count: record one
combined sync run per manual "Sync now" and count genuinely new
activities instead of re-listing whatever Garmin returned for the queried
window
- Let a Review Queue activity be manually cleared back to Unclassified, and
make "Reset all" available even while disconnected from Garmin
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-20 06:33:47 +02:00
|
|
|
target.HRMinPctHRR = &hrMin
|
|
|
|
|
target.HRMaxPctHRR = &hrMax
|
2026-07-17 18:53:55 +02:00
|
|
|
|
2026-07-25 13:44:06 +02:00
|
|
|
if err := db.UpdateWorkoutTypePace(ctx, userID, target); err != nil {
|
2026-07-17 18:53:55 +02:00
|
|
|
t.Fatalf("UpdateWorkoutTypePace: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-25 13:44:06 +02:00
|
|
|
got, err := db.GetWorkoutTypePace(ctx, userID, target.WorkoutKindID)
|
2026-07-17 18:53:55 +02:00
|
|
|
if err != nil {
|
|
|
|
|
t.Fatalf("GetWorkoutTypePace: %v", err)
|
|
|
|
|
}
|
|
|
|
|
if got.PaceMinSecPerKm == nil || *got.PaceMinSecPerKm != 330 {
|
|
|
|
|
t.Errorf("PaceMinSecPerKm = %v, want 330", got.PaceMinSecPerKm)
|
|
|
|
|
}
|
Dedup Garmin data storage, configurable chart colors, taxonomy fixes, sync/progression fixes
- Remove duplicated Garmin fields from storage; decode display-only fields
(activity name/type, lap duration/HR, structured workout raw JSON) from
RawJSON at API-response time instead of storing redundant columns
- Add a fully configurable chart color system (pace/HR main-line colors, 4
effort-kind colors, tint/darken/brighten intensity knobs) under Profile >
Chart colors
- Rename training types and fix their display order (Easy, Long, 60'/30'
Threshold, Tempo, Intervals, MAS Test, Race) everywhere they're listed
- Add an Efficiency Factor progression metric; fix Progression chart axes to
use tight non-zero-based domains, m:ss/km pace formatting, and rounded
ticks instead of raw floating-point labels
- Expose the raw get_workout_by_id() payload in the raw-data viewer
alongside activity/lap/detail JSON; enlarge the modal and shrink array
indentation for readability
- Fix "last sync" reporting a meaningless activity count: record one
combined sync run per manual "Sync now" and count genuinely new
activities instead of re-listing whatever Garmin returned for the queried
window
- Let a Review Queue activity be manually cleared back to Unclassified, and
make "Reset all" available even while disconnected from Garmin
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-20 06:33:47 +02:00
|
|
|
if got.HRMinPctHRR == nil || *got.HRMinPctHRR != 70 {
|
|
|
|
|
t.Errorf("HRMinPctHRR = %v, want 70", got.HRMinPctHRR)
|
|
|
|
|
}
|
|
|
|
|
if got.HRMaxPctHRR == nil || *got.HRMaxPctHRR != 80 {
|
|
|
|
|
t.Errorf("HRMaxPctHRR = %v, want 80", got.HRMaxPctHRR)
|
2026-07-17 18:53:55 +02:00
|
|
|
}
|
|
|
|
|
}
|