diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-27 19:07:33 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-27 19:07:33 +0200 |
| commit | 4a61f3eb3103aa512bef1b0d82295403bc4bc977 (patch) | |
| tree | 73eb78c50518f129d5e6aaa86153a1b4c4637bf5 /ride/store.go | |
| parent | d7b93325d4f70eeab369fa8a3c4cce9f0c4e0081 (diff) | |
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.
Diffstat (limited to 'ride/store.go')
| -rw-r--r-- | ride/store.go | 12 |
1 files changed, 11 insertions, 1 deletions
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) |
