Sessions: round odometer

This commit is contained in:
andig 2023-02-03 22:33:38 +01:00
parent 3c67646a5b
commit c150b2e0cc

View file

@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"math"
"net/http"
"strconv"
@ -50,9 +51,10 @@ func sessionHandler(w http.ResponseWriter, r *http.Request) {
if month != "" {
iMonth, err := strconv.Atoi(month)
if err != nil {
jsonError(w, http.StatusInternalServerError, err)
jsonError(w, http.StatusBadRequest, err)
return
}
fmtMonth = fmt.Sprintf("%02d", iMonth)
filename += "." + fmtMonth
}
@ -64,6 +66,11 @@ func sessionHandler(w http.ResponseWriter, r *http.Request) {
return
}
// prepare data
for _, s := range res {
s.Odometer = math.Round(s.Odometer*10) / 10
}
if r.URL.Query().Get("format") == "csv" {
lang := r.URL.Query().Get("lang")
if lang == "" {