From 6667ee479c06c14bb182f36a0a9ee704fca6218d Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Fri, 21 Aug 2026 07:08:53 +0200 Subject: feat(web): add sortable average speed column to ride library --- web/views.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'web/views.go') diff --git a/web/views.go b/web/views.go index 1bf1782..5422421 100644 --- a/web/views.go +++ b/web/views.go @@ -137,6 +137,7 @@ const ( rideSortStarted = "started" rideSortDistance = "distance" rideSortMovingTime = "moving_time" + rideSortSpeed = "speed" rideSortElevation = "elevation" rideSortCotacol = "cotacol" rideSortCotacolKm = "cotacol_100km" @@ -147,6 +148,7 @@ var rideSortColumns = map[string]bool{ rideSortStarted: true, rideSortDistance: true, rideSortMovingTime: true, + rideSortSpeed: true, rideSortElevation: true, rideSortCotacol: true, rideSortCotacolKm: true, @@ -167,6 +169,7 @@ func (s RideSort) databaseColumn() (rides.SortColumn, bool) { rideSortStarted: rides.SortStartDate, rideSortDistance: rides.SortDistance, rideSortMovingTime: rides.SortMovingTime, + rideSortSpeed: rides.SortSpeed, rideSortElevation: rides.SortElevation, rideSortCotacol: rides.SortCotacol, rideSortCotacolKm: rides.SortCotacolKm, @@ -189,6 +192,7 @@ func rideSortHeadersWithFilters(current RideSort, filters RideFilters) []RideSor {key: rideSortStarted, label: "Started"}, {key: rideSortDistance, label: "Distance", class: "numeric"}, {key: rideSortMovingTime, label: "Moving time", class: "numeric"}, + {key: rideSortSpeed, label: "Speed", class: "numeric"}, {key: rideSortElevation, label: "Elevation", class: "numeric"}, {key: rideSortCotacol, label: "Cotacol", class: "numeric"}, {key: rideSortCotacolKm, label: "Cotacol / 100 km", class: "numeric"}, @@ -355,6 +359,10 @@ func formatDistance(meters float64) string { return fmt.Sprintf("%.1f km", meters/1000) } +func formatSpeed(metersPerSecond float64) string { + return fmt.Sprintf("%.1f km/h", metersPerSecond*3.6) +} + func formatDuration(seconds int64) string { hours := seconds / 3600 minutes := (seconds % 3600) / 60 -- cgit v1.3