Waziup / api-server

3 stars 6 forks source link

lastN is not correct with Cloud timestamp #52

Open cdupont opened 5 years ago

cdupont commented 5 years ago

lastN returns the last N sensors, ordered by device timestamp:

$ curl -X GET "http://api.waziup.io/api/v1/sensors/LUMS_NODE_1/measurements/SM2/values?lastN=100" -H  "accept: application/json"
[
  {
    "timestamp": "2016-06-08T18:23:57.873Z",
    "value": 92,
    "date_received": "2019-02-14T06:36:26.000Z"
  },
  {
    "timestamp": "2016-06-08T18:23:57.873Z",
    "value": 91,
    "date_received": "2019-02-14T06:47:24.000Z"
  },
  {
    "timestamp": "2016-06-08T18:23:57.873Z",
    "value": 56,
    "date_received": "2019-02-14T07:17:45.000Z"
  }
]

However, if the device doesn't send this time (or a wrong one), this wouldn't work.