Changed endpoints and db queries, chart now shows suggested mins and maxes

This commit is contained in:
Daniel Ledda
2020-11-07 00:54:02 +01:00
parent 2ac185b969
commit 28b23d4899

View File

@@ -41,7 +41,7 @@ func writeSnapshotToDb(snapshotSub *SnapshotSubmission) error {
func getSnapshotRecordsFromDb(minuteAgo int) ([]*SnapshotRecord, error) { func getSnapshotRecordsFromDb(minuteAgo int) ([]*SnapshotRecord, error) {
snapshots := make([]*SnapshotRecord, minuteAgo) snapshots := make([]*SnapshotRecord, minuteAgo)
query := "SELECT `%s`, `%s`, `%s`, `%s`, `%s` FROM `snapshots` ORDER BY `id` DESC WHERE %s > date_sub(now(), interval %v minute);" query := "SELECT `%s`, `%s`, `%s`, `%s`, `%s` FROM `snapshots` ORDER BY `id` DESC WHERE `%s` > date_sub(now(), interval %v minute);"
rows, err := ClimateDb.Query(fmt.Sprintf(query, "id", "temp", "humidity", "co2", "time", "time", minuteAgo)) rows, err := ClimateDb.Query(fmt.Sprintf(query, "id", "temp", "humidity", "co2", "time", "time", minuteAgo))
if err != nil { if err != nil {
return nil, err return nil, err