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>
This commit is contained in:
@@ -8,6 +8,9 @@ import (
|
||||
// Profile is the single active user's Garmin credentials plus every
|
||||
// tunable analysis-engine parameter. Always exactly one row (id=1).
|
||||
type Profile struct {
|
||||
// Name labels this profile so a future multi-profile setup can show
|
||||
// which one is active. Only one profile row exists today (id=1).
|
||||
Name string
|
||||
GarminEmail string
|
||||
GarminPassword string
|
||||
RollingWindowDays int
|
||||
@@ -41,16 +44,40 @@ type Profile struct {
|
||||
// right as recording starts, before the run itself begins).
|
||||
MinRepresentativePaceSecPerKm, MinRepresentativeTimeSeconds float64
|
||||
|
||||
// Chart colors: PaceColor/HeartRateColor are the "main line" color for
|
||||
// each metric's chart; Warmup/Effort/Recovery/CooldownColor are the
|
||||
// "effort kind" colors. The frontend derives the under-the-line fill
|
||||
// (effort color tinted by the main line color) and the phase background
|
||||
// fill (effort color, darkened) from these six -- see
|
||||
// frontend's ExpectedVsActualChart.
|
||||
PaceColor, HeartRateColor string
|
||||
WarmupColor, EffortColor, RecoveryColor, CooldownColor string
|
||||
// MainLineTintPct (0-100) is how strongly the main line color mixes into
|
||||
// the effort-kind fill under the line -- see frontend's mixColor(). Never
|
||||
// affects the phase background above the line.
|
||||
MainLineTintPct float64
|
||||
// BackgroundDarkenPct (0-100) is how strongly the effort-kind color is
|
||||
// darkened for the phase background above the line -- see frontend's
|
||||
// darken(). Never mixed with the main line color.
|
||||
BackgroundDarkenPct float64
|
||||
// TargetBrightenPct (0-100) is how strongly a chart's main line color
|
||||
// (and everything tinted from it) is brightened when that chart has a
|
||||
// structured-workout target range to show -- a color cue for "this has a
|
||||
// target" instead of a text label -- see frontend's brighten().
|
||||
TargetBrightenPct float64
|
||||
|
||||
CreatedAt, UpdatedAt string
|
||||
}
|
||||
|
||||
const profileColumns = `
|
||||
garmin_email, garmin_password, rolling_window_days, backfill_horizon_days, max_heart_rate, resting_heart_rate,
|
||||
name, garmin_email, garmin_password, rolling_window_days, backfill_horizon_days, max_heart_rate, resting_heart_rate,
|
||||
hr_zone1_min_pct, hr_zone1_max_pct, hr_zone2_min_pct, hr_zone2_max_pct,
|
||||
hr_zone3_min_pct, hr_zone3_max_pct, hr_zone4_min_pct, hr_zone4_max_pct,
|
||||
hr_zone5_min_pct, hr_zone5_max_pct,
|
||||
warmup_minutes, cooldown_minutes,
|
||||
min_representative_pace_sec_per_km, min_representative_time_seconds,
|
||||
pace_color, heart_rate_color, warmup_color, effort_color, recovery_color, cooldown_color,
|
||||
main_line_tint_pct, background_darken_pct, target_brighten_pct,
|
||||
created_at, updated_at
|
||||
`
|
||||
|
||||
@@ -58,12 +85,14 @@ const profileColumns = `
|
||||
func (db *DB) GetProfile(ctx context.Context) (Profile, error) {
|
||||
var p Profile
|
||||
err := db.QueryRowContext(ctx, `SELECT `+profileColumns+` FROM profile WHERE id = 1`).Scan(
|
||||
&p.GarminEmail, &p.GarminPassword, &p.RollingWindowDays, &p.BackfillHorizonDays, &p.MaxHeartRate, &p.RestingHeartRate,
|
||||
&p.Name, &p.GarminEmail, &p.GarminPassword, &p.RollingWindowDays, &p.BackfillHorizonDays, &p.MaxHeartRate, &p.RestingHeartRate,
|
||||
&p.HRZone1MinPct, &p.HRZone1MaxPct, &p.HRZone2MinPct, &p.HRZone2MaxPct,
|
||||
&p.HRZone3MinPct, &p.HRZone3MaxPct, &p.HRZone4MinPct, &p.HRZone4MaxPct,
|
||||
&p.HRZone5MinPct, &p.HRZone5MaxPct,
|
||||
&p.WarmupMinutes, &p.CooldownMinutes,
|
||||
&p.MinRepresentativePaceSecPerKm, &p.MinRepresentativeTimeSeconds,
|
||||
&p.PaceColor, &p.HeartRateColor, &p.WarmupColor, &p.EffortColor, &p.RecoveryColor, &p.CooldownColor,
|
||||
&p.MainLineTintPct, &p.BackgroundDarkenPct, &p.TargetBrightenPct,
|
||||
&p.CreatedAt, &p.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -78,20 +107,24 @@ func (db *DB) GetProfile(ctx context.Context) (Profile, error) {
|
||||
func (db *DB) UpdateProfile(ctx context.Context, p Profile) error {
|
||||
_, err := db.ExecContext(ctx, `
|
||||
UPDATE profile SET
|
||||
garmin_email=?, garmin_password=?, rolling_window_days=?, backfill_horizon_days=?, max_heart_rate=?, resting_heart_rate=?,
|
||||
name=?, garmin_email=?, garmin_password=?, rolling_window_days=?, backfill_horizon_days=?, max_heart_rate=?, resting_heart_rate=?,
|
||||
hr_zone1_min_pct=?, hr_zone1_max_pct=?, hr_zone2_min_pct=?, hr_zone2_max_pct=?,
|
||||
hr_zone3_min_pct=?, hr_zone3_max_pct=?, hr_zone4_min_pct=?, hr_zone4_max_pct=?,
|
||||
hr_zone5_min_pct=?, hr_zone5_max_pct=?,
|
||||
warmup_minutes=?, cooldown_minutes=?,
|
||||
min_representative_pace_sec_per_km=?, min_representative_time_seconds=?,
|
||||
pace_color=?, heart_rate_color=?, warmup_color=?, effort_color=?, recovery_color=?, cooldown_color=?,
|
||||
main_line_tint_pct=?, background_darken_pct=?, target_brighten_pct=?,
|
||||
updated_at=datetime('now')
|
||||
WHERE id = 1`,
|
||||
p.GarminEmail, p.GarminPassword, p.RollingWindowDays, p.BackfillHorizonDays, p.MaxHeartRate, p.RestingHeartRate,
|
||||
p.Name, p.GarminEmail, p.GarminPassword, p.RollingWindowDays, p.BackfillHorizonDays, p.MaxHeartRate, p.RestingHeartRate,
|
||||
p.HRZone1MinPct, p.HRZone1MaxPct, p.HRZone2MinPct, p.HRZone2MaxPct,
|
||||
p.HRZone3MinPct, p.HRZone3MaxPct, p.HRZone4MinPct, p.HRZone4MaxPct,
|
||||
p.HRZone5MinPct, p.HRZone5MaxPct,
|
||||
p.WarmupMinutes, p.CooldownMinutes,
|
||||
p.MinRepresentativePaceSecPerKm, p.MinRepresentativeTimeSeconds,
|
||||
p.PaceColor, p.HeartRateColor, p.WarmupColor, p.EffortColor, p.RecoveryColor, p.CooldownColor,
|
||||
p.MainLineTintPct, p.BackgroundDarkenPct, p.TargetBrightenPct,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("update profile: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user