refactor(db): round averages in SQL queries
Signed-off-by: Klagarge <remi@heredero.ch>
This commit is contained in:
@@ -344,9 +344,9 @@ func (g *RestGateway) getRoomCurrent(c *gin.Context) {
|
|||||||
query := fmt.Sprintf(`
|
query := fmt.Sprintf(`
|
||||||
SELECT
|
SELECT
|
||||||
date_bin(INTERVAL '5 minutes', time) AS time,
|
date_bin(INTERVAL '5 minutes', time) AS time,
|
||||||
AVG(co2_ppm) AS co2_ppm,
|
ROUND(AVG(co2_ppm)) AS co2_ppm,
|
||||||
AVG(temp) AS temp,
|
ROUND(AVG(temp), 2) AS temp,
|
||||||
AVG(humidity) AS humidity,
|
ROUND(AVG(humidity), 2) AS humidity,
|
||||||
MAX(window_open) AS window_open
|
MAX(window_open) AS window_open
|
||||||
FROM "%s"
|
FROM "%s"
|
||||||
WHERE time > now() - INTERVAL '1 day'
|
WHERE time > now() - INTERVAL '1 day'
|
||||||
@@ -403,9 +403,9 @@ func (g *RestGateway) getRoomHistory(c *gin.Context) {
|
|||||||
query := fmt.Sprintf(`
|
query := fmt.Sprintf(`
|
||||||
SELECT
|
SELECT
|
||||||
date_bin(INTERVAL '5 minutes', time) AS time,
|
date_bin(INTERVAL '5 minutes', time) AS time,
|
||||||
AVG(co2_ppm) AS co2_ppm,
|
ROUND(AVG(co2_ppm)) AS co2_ppm,
|
||||||
AVG(temp) AS temp,
|
ROUND(AVG(temp), 2) AS temp,
|
||||||
AVG(humidity) AS humidity,
|
ROUND(AVG(humidity), 2) AS humidity,
|
||||||
MAX(window_open) AS window_open
|
MAX(window_open) AS window_open
|
||||||
FROM "%s"
|
FROM "%s"
|
||||||
WHERE time > now() - INTERVAL '%s'
|
WHERE time > now() - INTERVAL '%s'
|
||||||
|
|||||||
Reference in New Issue
Block a user