Database request in dbGetLastDay and other avg calculating functions is implemented too bad, so it's worth to rewrite it, probably using group by, but in this case there are some issues with those days, when there were no data from sensors.
|
for i := 0; i < 24; i++ { |
|
err = db.QueryRow(`SELECT AVG(value_sensor) AS "Average value" FROM "fict_sensors_syn" where id_sensor=$1 and |
|
time_add >= now() - $2::INTERVAL and time_add <= now() - $3::INTERVAL`, sensId, strconv.Itoa(i+1)+" hour", strconv.Itoa(i)+" hour").Scan(&value) |
|
if err != nil { |
|
value = 10000 |
|
} |
|
valueArr = append(valueArr, math.Round(value*100)/100) |
|
err = nil |
|
} |
Database request in
dbGetLastDayand other avg calculating functions is implemented too bad, so it's worth to rewrite it, probably usinggroup by, but in this case there are some issues with those days, when there were no data from sensors.server/dbase.go
Lines 107 to 115 in 8c5b6da