diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-21 07:08:53 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-21 07:08:53 +0200 |
| commit | 6667ee479c06c14bb182f36a0a9ee704fca6218d (patch) | |
| tree | b53949334dae62d9da56ccdf76d958a0cc9db004 /web/views.go | |
| parent | 9da52d7355f5a77f0adc9a658619b3bfef03ba3c (diff) | |
feat(web): add sortable average speed column to ride library
Diffstat (limited to 'web/views.go')
| -rw-r--r-- | web/views.go | 8 |
1 files changed, 8 insertions, 0 deletions
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 |
