From 53615a05708ff852af42905e2b5ced66ba70c43d Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Sun, 23 Aug 2026 11:09:07 +0200 Subject: 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. --- web/rides.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'web/rides.go') diff --git a/web/rides.go b/web/rides.go index cb38b3c..477f066 100644 --- a/web/rides.go +++ b/web/rides.go @@ -9,7 +9,6 @@ import ( "github.com/martinlehoux/biking_home/mountain_pass" "github.com/martinlehoux/biking_home/official_climb" "github.com/martinlehoux/biking_home/ride" - "github.com/martinlehoux/biking_home/rides" "github.com/martinlehoux/kagamigo/kcore" ) @@ -41,7 +40,7 @@ func (s *Server) handleRide(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) return } - item, found, err := rides.GetByID(s.db, id) + item, found, err := ride.GetByID(s.db, id) if err != nil { slog.Error("Failed to load ride", "ride_id", id, "error", err) http.Error(w, "failed to load ride", http.StatusInternalServerError) @@ -103,7 +102,7 @@ func (s *Server) handleAnalytics(w http.ResponseWriter, r *http.Request) { if filters.DistanceMaxKm != nil { maxKm = *filters.DistanceMaxKm } - eligible := make([]rides.Ride, 0, len(items)) + eligible := make([]ride.StoredRide, 0, len(items)) for _, item := range items { distanceKm := int(item.DistanceM / 1000) if distanceKm < minKm || (maxKm != 0 && distanceKm > maxKm) { @@ -130,7 +129,7 @@ func (s *Server) handleCreateOfficialClimb(w http.ResponseWriter, r *http.Reques http.NotFound(w, r) return } - item, found, err := rides.GetByID(s.db, id) + item, found, err := ride.GetByID(s.db, id) if err != nil { slog.Error("Failed to load ride for official climb creation", "ride_id", id, "error", err) http.Error(w, "failed to load ride", http.StatusInternalServerError) @@ -190,18 +189,18 @@ func parseRouteIndex(value string) (int, error) { return index, nil } -func (s *Server) listRides(rideSort RideSort) ([]rides.Ride, error) { +func (s *Server) listRides(rideSort RideSort) ([]ride.StoredRide, error) { column, found := rideSort.databaseColumn() if !found { - return rides.List(s.db) + return ride.List(s.db) } - return rides.ListSorted(s.db, column, rideSort.Descending) + return ride.ListSorted(s.db, column, rideSort.Descending) } const minimumDisplayedDistanceM = 10_000 const rideDetailMountainPassMarginM = 10_000 -func buildRideViews(items []rides.Ride) []RideView { +func buildRideViews(items []ride.StoredRide) []RideView { views := make([]RideView, 0, len(items)) for _, item := range items { if item.DistanceM < minimumDisplayedDistanceM { @@ -212,7 +211,7 @@ func buildRideViews(items []rides.Ride) []RideView { return views } -func buildRideView(item rides.Ride) RideView { +func buildRideView(item ride.StoredRide) RideView { view := RideView{Ride: item, Cotacol: "-", CotacolPer100Km: "-", MovingTime: formatDuration(item.EffectiveMovingTimeS())} cotacol, ready := item.CotacolScore() if ready && item.CotacolAlgorithmVersion() == ride.CotacolAlgorithmVersion && item.DistanceM > 0 { -- cgit v1.3