Closed timcowlishaw closed 11 months ago
Tested in staging. Very good work!
{"device_id":"16602","sensor_key":null,"sensor_id":550,"component_id":null,"rollup":"1m","function":"avg","from":"2010-01-01","to":null,"sample_size":0,"readings":[]}
https://staging-api.smartcitizen.me/v0/devices/16602/readings?sensor_id=55&rollup=1m&from=2010-01-01
{"device_id":16602,"sensor_key":"t","sensor_id":55,"component_id":240,"rollup":"1m","function":"avg","from":"2010-01-01T00:00:00Z","to":"2023-10-27T09:38:52Z","sample_size":9,"readings":[["2023-10-27T09:38:20Z",23.92],["2023-10-27T09:37:20Z",24.07],["2023-10-27T09:36:20Z",24.05],["2023-10-27T09:35:20Z",23.98],["2023-10-27T09:34:20Z",24.05],["2023-10-27T09:33:20Z",24.02],["2023-10-27T09:32:20Z",24.08],["2023-10-27T09:31:20Z",24.02],["2023-10-27T09:30:20Z",24.25]]}
Fixes #275
Currently, we 500 when searching for readings for a sensor which isn't present on a device. This PR instead returns a meaningful empty response: