Changed endpoints and db queries, chart now shows suggested mins and maxes
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user