[openstreetmap/openstreetmap-website] Add order parameter to changeset query API call (PR #4158)
Anton Khorev
notifications at github.com
Sat Aug 12 01:57:23 UTC 2023
When you want to get an unknown number of changesets matching some criteria, you use `/api/0.6/changesets` with the corresponding parameters. If you receive a number of changesets that is equal to the limit, you know there might be more matching changesets. To get the next page of changesets you set the upper limit of the `time` parameter to the last received changeset.* The lower limit is usually set to some date before osm existed. Then you run the query again and receive the next page of results. That next page should consist of changesets created earlier than the ones received previously.
But what if you want a previous page? You can't set the upper time limit to the first received changeset because you'll get the same result again.* You can set the lower limit, but then you'll still need to decide on the upper limit. If you don't set the upper limit, you'll receive the first page with the latest changesets, not the previous one. You'll have to guess the upper time limit of the previous page, and guessing it correctly may take several requests.
If you could get changesets in ascending order, specifying lower limit would be enough to get the previous page.*
This pull request adds the `order` parameter to `/api/0.6/changesets`, similar to `/api/0.6/notes/search`. `order=oldest` returns changesets in ascending order.
\* some details about same-second and overlapping changesets omitted
You can view, comment on, or merge this pull request online at:
https://github.com/openstreetmap/openstreetmap-website/pull/4158
-- Commit Summary --
* Add ordered changeset test method
* Add order parameter to changeset query api entry point
-- File Changes --
M app/controllers/api/changesets_controller.rb (11)
M test/controllers/api/changesets_controller_test.rb (53)
-- Patch Links --
https://github.com/openstreetmap/openstreetmap-website/pull/4158.patch
https://github.com/openstreetmap/openstreetmap-website/pull/4158.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4158
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/4158 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20230811/097330c6/attachment.htm>
More information about the rails-dev
mailing list