From 5a522245c12a1a6e4bf4c2923983e31ba4f59fa6 Mon Sep 17 00:00:00 2001 From: Daniel Ledda Date: Sat, 7 Nov 2020 01:01:30 +0100 Subject: [PATCH] Changed endpoints and db queries, chart now shows suggested mins and maxes --- Database.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Database.go b/Database.go index 0cfd131..2dd92bc 100644 --- a/Database.go +++ b/Database.go @@ -40,7 +40,7 @@ func writeSnapshotToDb(snapshotSub *SnapshotSubmission) error { } func getSnapshotRecordsFromDb(minuteAgo int) ([]*SnapshotRecord, error) { - snapshots := make([]*SnapshotRecord) + snapshots := make([]*SnapshotRecord, 0) query := "SELECT `%s`, `%s`, `%s`, `%s`, `%s` FROM `snapshots` WHERE `%s` > date_sub(now(), interval %v minute) ORDER BY `id` DESC;" rows, err := ClimateDb.Query(fmt.Sprintf(query, "id", "temp", "humidity", "co2", "time", "time", minuteAgo)) if err != nil { @@ -58,7 +58,7 @@ func getSnapshotRecordsFromDb(minuteAgo int) ([]*SnapshotRecord, error) { if err != nil { return nil, err } - snapshots[i] = &snapshotRecord + snapshots = append(snapshots, &snapshotRecord) } return snapshots, nil } \ No newline at end of file