Skip to content

[Improve database requests] #9

Description

@dedifferentiator

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.

server/dbase.go

Lines 107 to 115 in 8c5b6da

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions