Add Race workout kind with Garmin eventType auto-detection, sync-time running filter, and pill-based review queue filter
Race is the 8th fixed workout kind, seeded with a real (not placeholder) rule since Garmin Connect's eventType.typeKey reports "race" for manually-tagged race activities. Non-running activity types (padel, cycling, strength training, ...) are now dropped at sync time instead of being stored. The Review Queue's type filter is now clickable exclusive pill buttons instead of a dropdown.
This commit is contained in:
@@ -2,6 +2,7 @@ package sync
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"smartrun/backend/internal/classify"
|
||||
@@ -9,11 +10,21 @@ import (
|
||||
"smartrun/backend/internal/store"
|
||||
)
|
||||
|
||||
// isRunningActivityType reports whether a Garmin activityType.typeKey
|
||||
// represents a running activity (running, trail_running, treadmill_running,
|
||||
// track_running, indoor_running, virtual_run, ...) as opposed to other
|
||||
// sports (padel, cycling, strength training, ...) that also show up in
|
||||
// get_activities().
|
||||
func isRunningActivityType(typeKey string) bool {
|
||||
return strings.Contains(strings.ToLower(typeKey), "run")
|
||||
}
|
||||
|
||||
func toActivityRow(a garmin.Activity) store.Activity {
|
||||
return store.Activity{
|
||||
GarminActivityID: a.ActivityID,
|
||||
ActivityName: a.ActivityName,
|
||||
ActivityType: a.ActivityType.TypeKey,
|
||||
EventTypeKey: a.EventType.TypeKey,
|
||||
StartTimeUTC: a.StartTimeGMT,
|
||||
BeginTimestampMs: a.BeginTimestamp,
|
||||
DurationSeconds: a.Duration,
|
||||
@@ -125,9 +136,14 @@ func toSampleRows(samples []garmin.Sample) []store.Sample {
|
||||
// rules. maxHR is the user's configured max heart rate, used only to derive
|
||||
// avg_hr_pct_max (Garmin's activity/lap summaries don't include it directly).
|
||||
func buildMetricContext(a store.Activity, laps []store.Lap, maxHR float64) classify.MetricContext {
|
||||
isRace := 0.0
|
||||
if a.EventTypeKey == "race" {
|
||||
isRace = 1.0
|
||||
}
|
||||
ctx := classify.MetricContext{
|
||||
"duration_seconds": a.DurationSeconds,
|
||||
"distance_meters": a.DistanceMeters,
|
||||
"is_race": isRace,
|
||||
}
|
||||
if a.AvgSpeedMps != nil && *a.AvgSpeedMps > 0 {
|
||||
ctx["avg_pace_sec_per_km"] = 1000 / *a.AvgSpeedMps
|
||||
|
||||
Reference in New Issue
Block a user