tempestas

A REST API for processing sensor.community data
git clone https://git.bracken.jp/tempestas.git
Log | Files | Refs | README | LICENSE

commit 25d133eb8cd1076030b01837e9373a6079967e8d
parent 37a74914f4cbe39a9f292482f60d2b23fea0cf10
Author: Chris Bracken <chris@bracken.jp>
Date:   Fri, 12 Nov 2021 23:56:43 -0800

Rename Sensor.SensorId to Sensor.Id

Diffstat:
Mstatic/tempestas.js | 3++-
Mstorage/storage.go | 6+++---
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/static/tempestas.js b/static/tempestas.js @@ -19,7 +19,8 @@ fetch(sensorUrl) .then((response) => { return response.json(); }) .then((data) => { data.forEach((sensor, i) => { - sensors.push({id: sensor.sensor_id, name: sensor.name, color: colors[i]}); + sensor.color = colors[i]; + sensors.push(sensor); }); charts.forEach((chart, i) => sensorReadings[chart.id] = {}); sensors.forEach((sensor, i) => fetchSensorData(sensor.id, charts[0])); diff --git a/storage/storage.go b/storage/storage.go @@ -29,8 +29,8 @@ type Reading struct { } type Sensor struct { - SensorId string `json:"sensor_id"` - Name string `json:"name"` + Id string `json:"id"` + Name string `json:"name"` } type DataStore interface { @@ -108,7 +108,7 @@ func (s *PostgresDataStore) QuerySensors() ([]Sensor, error) { var sensors []Sensor for rows.Next() { var s Sensor - if err := rows.Scan(&s.SensorId, &s.Name); err != nil { + if err := rows.Scan(&s.Id, &s.Name); err != nil { return sensors, err } sensors = append(sensors, s)