Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination of datapoints #28

Closed
cdupont opened this issue Feb 6, 2018 · 9 comments
Closed

Pagination of datapoints #28

cdupont opened this issue Feb 6, 2018 · 9 comments
Assignees

Comments

@cdupont
Copy link
Contributor

cdupont commented Feb 6, 2018

To help retrieving big amounts of sensor datapoints, we need to use a pagination mechanism.
We can use those query strings:

  • vLastN: Only the requested last datapoints will be returned. Datapoints are sorted with the most recent datapoint first. It is on by default, with a value of 20.
  • vLimit: In case of pagination, the number of datapoints per page.
  • vOffset: In case of pagination, the offset to apply to the requested search of datapoints.
  • vDateFrom: The starting date and time from which the datapoints are desired. It is an optional parameter.
  • vDateTo: The final date and time until which the datapoints are desired. It is an optional parameter.

Example of query:

curl -X GET "http://dev.waziup.io:80/api/v1/domains/waziup/sensors/mySensor/measurements/TC/values?vLimit=50&vOffset=0&vDateFrom=2016-01-01T00:00:00.000Z&vDateTo=2016-01-31T23:59:59.999Z"

This query will retrieve the first 50 datapoints from January 2016.

@cdupont cdupont self-assigned this Feb 6, 2018
@cdupont
Copy link
Contributor Author

cdupont commented Feb 7, 2018

Note that Orion already have pagination:
https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/user/pagination.md
This works for sensors and entities, but not datapoint as they are stored in Mongo.

@cdupont
Copy link
Contributor Author

cdupont commented Feb 7, 2018

Done: 98e58e8

@cdupont
Copy link
Contributor Author

cdupont commented Feb 8, 2018

@henokzion Could you validate and close this issue?

@henokzion
Copy link

It's working correctly

@cdupont
Copy link
Contributor Author

cdupont commented Feb 14, 2018

@henokzion I extended the pagination mechanism to all GET endpoints in /sensors.
i.e.:
GET /domains/{domain}/sensors
GET /domains/{domain}/sensors/{sensor_id}
GET /domains/{domain}/sensors/{sensor_id}/measurements
GET /domains/{domain}/sensors/{sensor_id}/measurements/{measurement_id}
GET /domains/{domain}/sensors/{sensor_id}/measurements/{measurement_id}/values

The pagination will limit the number of datapoint returned.
@henokzion Could you test also?

@cdupont cdupont reopened this Feb 14, 2018
@henokzion
Copy link

GET /domains/{domain}/sensors
for this request we could limit the pagination to the sensors themselves and show only the last values with the sensors.
GET /domains/{domain}/sensors/{sensor_id}
here also we could show the last value
GET /domains/{domain}/sensors/{sensor_id}/measurements
here also we could show the last value for each of the measurement
GET /domains/{domain}/sensors/{sensor_id}/measurements/{measurement_id}
here we could paginate the value of the given measurement

@cdupont
Copy link
Contributor Author

cdupont commented Feb 16, 2018

OK great, I'll do that.

@cdupont
Copy link
Contributor Author

cdupont commented Feb 16, 2018

This is what I did:

  • GET /domains/{domain}/sensors
    • only limit, offset are applied to the list the sensors
    • only the last measurement value is returned
  • GET /domains/{domain}/sensors/{sensor_id}
    • no pagination necessary
    • only the last measurement value is returned
  • GET /domains/{domain}/sensors/{sensor_id}/measurements
    • no pagination necessary
    • only the last measurement value is returned
  • GET /domains/{domain}/sensors/{sensor_id}/measurements/{measurement_id}
    • no pagination necessary
    • only the last measurement value is returned
  • GET /domains/{domain}/sensors/{sensor_id}/measurements/{measurement_id}/value
    • lastN, limit, offset, dateFrom, dateTo are applied to the list of values

@cdupont cdupont assigned henokzion and unassigned cdupont Feb 16, 2018
@henokzion
Copy link

I will test it right away

@cdupont cdupont closed this as completed Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants