Waziup / api-server

3 stars 6 forks source link

Get sensors: number of sensors returned is not correct #50

Open cdupont opened 6 years ago

cdupont commented 6 years ago

When retrieving a number of sensors, less might be returned. For example, retrieving 20 sensors might yield 16. It's because we retrieve 20 sensors from Orion database, and then remove the one you don't have access to. So the remainder is 16.

cdupont commented 6 years ago

Solution could be to retrieve more sensors from Orion, and apply the limit after filtering. With request /sensors?limit=100?offset=100: -> retrieve all sensors from Orion (with several requests if more than 1000) -> filter them with KC permissions -> eliminate offset number of sensors -> return limit number of sensors

This technique might be slow because we retrieve a lot of sensors and ask permissions for all.