aboutsummaryrefslogtreecommitdiff
path: root/web/rides.go
diff options
context:
space:
mode:
Diffstat (limited to 'web/rides.go')
-rw-r--r--web/rides.go17
1 files changed, 8 insertions, 9 deletions
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 {