From 4a61f3eb3103aa512bef1b0d82295403bc4bc977 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Thu, 27 Aug 2026 19:07:33 +0200 Subject: Swap ride read path from GPX to FIT for performance Always use FIT for detail, official climb creation and backtest; keep GPX fallback for legacy rides pending backfill. FIT is 10-20x smaller and parses without XML. --- ride/store.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'ride/store.go') diff --git a/ride/store.go b/ride/store.go index f6de535..9429acf 100644 --- a/ride/store.go +++ b/ride/store.go @@ -56,7 +56,17 @@ func Save(db *sql.DB, r StoredRide) error { var cotacolAlgorithmVersion any var movingTimeS any var movingTimeAlgorithmVersion any - if r.GPXPath != "" { + if r.FitPath != "" { + parsed, err := ParseFile(FITRideParser{}, r.FitPath) + if err != nil { + return fmt.Errorf("compute ride values for %q: %w", r.ExternalID, err) + } + cotacolScore = climb.Cotacol(parsed.Distances, parsed.Elevations) + cotacolAlgorithmVersion = climb.CotacolAlgorithmVersion + movingTimeS = int64(MovingTime(parsed) / time.Second) + movingTimeAlgorithmVersion = MovingTimeAlgorithmVersion + } else if r.GPXPath != "" { + // Legacy fallback for rides created before FIT (e.g. tests). parsed, err := ParseFile(GPXRideParser{}, r.GPXPath) if err != nil { return fmt.Errorf("compute ride values for %q: %w", r.ExternalID, err) -- cgit v1.3