diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-09-06 12:38:16 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-09-06 12:38:16 +0200 |
| commit | 8e0c55230ef59869bda1ca19ca8697b447d57698 (patch) | |
| tree | 2d5941e95949c43a84326cc5d10db8e4fab72a64 /web/rides.go | |
| parent | 28a7c9f281c16d1928b37dd1afdfe8399b7a03f8 (diff) | |
Preview: analyze a raw GPX or FIT file without persisting it
Diffstat (limited to 'web/rides.go')
| -rw-r--r-- | web/rides.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/web/rides.go b/web/rides.go index c945801..37340b8 100644 --- a/web/rides.go +++ b/web/rides.go @@ -86,15 +86,9 @@ func (s *Server) handleRide(w http.ResponseWriter, r *http.Request) { if err != nil { slog.Warn("Failed to load official climbs for ride detail", "ride_id", id, "error", err) } - matchPolicy := official_climb.DefaultMatchPolicy() - appConfig, err := s.loadConfig() - if err != nil { - slog.Warn("Failed to load official climb matching configuration", "ride_id", id, "error", err) - } else { - matchPolicy.EndpointRadiusM = appConfig.OfficialClimb.MatchRadiusM - } + matchPolicy := s.officialClimbMatchPolicy() slog.Info("Loaded ride detail", "ride_id", id) - view := buildRideDetailView(item, parsed, passes, officialClimbs, matchPolicy) + view := buildRideDetailView(buildRideView(item), parsed, passes, officialClimbs, matchPolicy) view.Notice = rideDetailNotice(r) kcore.RenderPage(r.Context(), RideDetailPage(view), w) } @@ -186,6 +180,18 @@ func (s *Server) handleCreateOfficialClimb(w http.ResponseWriter, r *http.Reques http.Redirect(w, r, rideDetailURL(id)+"?official_climb=created", http.StatusSeeOther) } +// officialClimbMatchPolicy loads the configured endpoint radius, falling back to the default. +func (s *Server) officialClimbMatchPolicy() official_climb.MatchPolicy { + matchPolicy := official_climb.DefaultMatchPolicy() + appConfig, err := s.loadConfig() + if err != nil { + slog.Warn("Failed to load official climb matching configuration", "error", err) + return matchPolicy + } + matchPolicy.EndpointRadiusM = appConfig.OfficialClimb.MatchRadiusM + return matchPolicy +} + func parseRouteIndex(value string) (int, error) { index, err := strconv.Atoi(value) if err != nil || index < 0 { |
