From 3ff484359eaa8f3ef8753e950f63a13917563a33 Mon Sep 17 00:00:00 2001 From: Klagarge Date: Sat, 30 May 2026 00:34:39 +0200 Subject: [PATCH] refactor(db): round averages in SQL queries Signed-off-by: Klagarge --- db/src/rest/rest.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/src/rest/rest.go b/db/src/rest/rest.go index ff69d59..49ecfb5 100644 --- a/db/src/rest/rest.go +++ b/db/src/rest/rest.go @@ -344,9 +344,9 @@ func (g *RestGateway) getRoomCurrent(c *gin.Context) { query := fmt.Sprintf(` SELECT date_bin(INTERVAL '5 minutes', time) AS time, - AVG(co2_ppm) AS co2_ppm, - AVG(temp) AS temp, - AVG(humidity) AS humidity, + ROUND(AVG(co2_ppm)) AS co2_ppm, + ROUND(AVG(temp), 2) AS temp, + ROUND(AVG(humidity), 2) AS humidity, MAX(window_open) AS window_open FROM "%s" WHERE time > now() - INTERVAL '1 day' @@ -403,9 +403,9 @@ func (g *RestGateway) getRoomHistory(c *gin.Context) { query := fmt.Sprintf(` SELECT date_bin(INTERVAL '5 minutes', time) AS time, - AVG(co2_ppm) AS co2_ppm, - AVG(temp) AS temp, - AVG(humidity) AS humidity, + ROUND(AVG(co2_ppm)) AS co2_ppm, + ROUND(AVG(temp), 2) AS temp, + ROUND(AVG(humidity), 2) AS humidity, MAX(window_open) AS window_open FROM "%s" WHERE time > now() - INTERVAL '%s'