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(`
|
||||
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'
|
||||
|
||||
Reference in New Issue
Block a user