thomersch / openstreetmap-calendar

osmcal, a Collaborative Calendar for OpenStreetMap-related Events
https://osmcal.org
Apache License 2.0
33 stars 9 forks source link

Add parameter to specify count of results in API #30

Closed jbelien closed 4 years ago

jbelien commented 4 years ago

What is the current count limit in the API results ? It would be nice to be able to specify via a count or limit parameter the number of results we want.

For instance, show me the next 5 events or the last 3.

Thanks !

thomersch commented 4 years ago

Heh, when I was building the API I was already anticipating you'd ask that ;)

So, at the moment it's all events in the future, because it's not that much data for now. And for the past, it's the last 20, which is completely arbitrary.

Paging in APIs is always kind of ugly: Either we need to put a wrapper object with some info about the current page (how many results, are there more, what is the url for the next page, ...) or we'd at least need some header values. Not sure about what's the cleanest way.

We could do a rudimentary limit and skip/offset for the moment, but this would be bad for caching, at least as soon as osmcal starts world domination.

So maybe, for the moment, just a limit parameter with allowed values up to 20?

jbelien commented 4 years ago

Heh, when I was building the API I was already anticipating you'd ask that ;)

You know me so well 😂

So maybe, for the moment, just a limit parameter with allowed values up to 20?

Don't bother (for now). I added a parameter in my widget to filter client-side. https://github.com/jbelien/openstreetmap-calendar-widget/blob/master/src/Widget.ts#L43-L45

I think it's good enough at the moment (while waiting for a smart pagination system :P).

It's just good to know it's:

Does the 20 limit applies before (or after) the country filter ?

thomersch commented 4 years ago

Does the 20 limit applies before (or after) the country filter ?

After filtering. You'll always get up to 20.

thomersch commented 4 years ago

I’ll close here for now, until we need something more elaborate 😊