From c150b2e0cccab3e09bd89f780e77dcea2294f8d2 Mon Sep 17 00:00:00 2001 From: andig Date: Fri, 3 Feb 2023 22:33:38 +0100 Subject: [PATCH] Sessions: round odometer --- server/http_session_handler.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/http_session_handler.go b/server/http_session_handler.go index b83fb3a7d..49f6c6c8c 100644 --- a/server/http_session_handler.go +++ b/server/http_session_handler.go @@ -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 == "" {