diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-23 11:09:07 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-23 11:09:07 +0200 |
| commit | 53615a05708ff852af42905e2b5ced66ba70c43d (patch) | |
| tree | 5f936b6bb8a2305cff6c8d086e6ad5af4c1aa491 /cli | |
| parent | 765ea1fffcc1bd1af2e6e9645d6f138dfd4ae0eb (diff) | |
Merge ride and rides packages into ride/store following mountain_pass structure
Consolidate persistence (Save, List, Backfill) into ride/store.go alongside
ride.go/climb.go/moving_time.go, rename rides.Ride to ride.StoredRide to
avoid collision with parsed ride.Ride, update all web/cli consumers and
RideView to use named Ride field, adjust templates and regenerate templ files,
and remove rides directory.
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/cli.go | 7 | ||||
| -rw-r--r-- | cli/cli_test.go | 12 |
2 files changed, 9 insertions, 10 deletions
@@ -16,7 +16,6 @@ import ( "github.com/martinlehoux/biking_home/config" "github.com/martinlehoux/biking_home/mountain_pass" "github.com/martinlehoux/biking_home/ride" - "github.com/martinlehoux/biking_home/rides" "github.com/martinlehoux/biking_home/web" "github.com/martinlehoux/kagamigo/kcore" ) @@ -42,7 +41,7 @@ func Run(db *sql.DB, configPath string, appConfig config.Config) { _, err := mountain_pass.ExtractMountainPasses(context.Background(), *extractOSM, db) kcore.Expect(err, "failed to extract mountain passes from OSM") case *backfill: - count, err := rides.Backfill(db) + count, err := ride.Backfill(db) kcore.Expect(err, "failed to backfill ride values") slog.Info("Backfilled ride values", "rides", count) case *backtest: @@ -67,7 +66,7 @@ type backtestSample struct { } func runBacktest(db *sql.DB) error { - items, err := rides.List(db) + items, err := ride.List(db) if err != nil { return err } @@ -128,7 +127,7 @@ func runBacktest(db *sql.DB) error { return nil } -func isBacktestEligible(item rides.Ride) bool { +func isBacktestEligible(item ride.StoredRide) bool { return item.GPXPath != "" && item.DistanceM >= backtestMinimumDistanceM && item.ExternalMovingTimeS > 0 && diff --git a/cli/cli_test.go b/cli/cli_test.go index 7964387..3e2afe2 100644 --- a/cli/cli_test.go +++ b/cli/cli_test.go @@ -3,22 +3,22 @@ package cli import ( "testing" - "github.com/martinlehoux/biking_home/rides" + "github.com/martinlehoux/biking_home/ride" "github.com/stretchr/testify/assert" ) func TestBacktestEligibilityExcludesShortDistances(t *testing.T) { - short := rides.Ride{GPXPath: "ride.gpx", DistanceM: 10_000 - 1, ExternalMovingTimeS: 8_000, ElapsedTimeS: 10_000} - minimum := rides.Ride{GPXPath: "ride.gpx", DistanceM: 10_000, ExternalMovingTimeS: 8_000, ElapsedTimeS: 10_000} + short := ride.StoredRide{GPXPath: "ride.gpx", DistanceM: 10_000 - 1, ExternalMovingTimeS: 8_000, ElapsedTimeS: 10_000} + minimum := ride.StoredRide{GPXPath: "ride.gpx", DistanceM: 10_000, ExternalMovingTimeS: 8_000, ElapsedTimeS: 10_000} assert.False(t, isBacktestEligible(short)) assert.True(t, isBacktestEligible(minimum)) } func TestBacktestEligibilityExcludesLowMovingRatio(t *testing.T) { - low := rides.Ride{GPXPath: "ride.gpx", DistanceM: 10_000, ExternalMovingTimeS: 7_999, ElapsedTimeS: 10_000} - boundary := rides.Ride{GPXPath: "ride.gpx", DistanceM: 10_000, ExternalMovingTimeS: 8_000, ElapsedTimeS: 10_000} - noElapsed := rides.Ride{GPXPath: "ride.gpx", DistanceM: 10_000, ExternalMovingTimeS: 1} + low := ride.StoredRide{GPXPath: "ride.gpx", DistanceM: 10_000, ExternalMovingTimeS: 7_999, ElapsedTimeS: 10_000} + boundary := ride.StoredRide{GPXPath: "ride.gpx", DistanceM: 10_000, ExternalMovingTimeS: 8_000, ElapsedTimeS: 10_000} + noElapsed := ride.StoredRide{GPXPath: "ride.gpx", DistanceM: 10_000, ExternalMovingTimeS: 1} assert.False(t, isBacktestEligible(low)) assert.True(t, isBacktestEligible(boundary)) |
