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

This commit is contained in:
Daniel Ledda
2020-11-07 00:55:19 +01:00
parent 28b23d4899
commit 9dd7bf496b

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` 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)) 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