fix pagination for features/records (#1658) (#1754)

* fix pagination for features/records (#1658)

* remove given tests already existing
This commit is contained in:
Tom Kralidis
2024-07-24 08:56:50 -04:00
committed by GitHub
parent d600f55214
commit 7bb7b38016
+17 -11
View File
@@ -531,17 +531,23 @@ def get_collection_items(
'href': f'{uri}?offset={prev}{serialized_query_params}'
})
if 'numberMatched' in content:
if content['numberMatched'] > (limit + offset):
next_ = offset + limit
next_href = f'{uri}?offset={next_}{serialized_query_params}'
content['links'].append(
{
'type': 'application/geo+json',
'rel': 'next',
'title': l10n.translate('Items (next)', request.locale),
'href': next_href
})
next_link = False
if content.get('numberMatched', -1) > (limit + offset):
next_link = True
elif len(content['features']) == limit:
next_link = True
if next_link:
next_ = offset + limit
next_href = f'{uri}?offset={next_}{serialized_query_params}'
content['links'].append(
{
'type': 'application/geo+json',
'rel': 'next',
'title': l10n.translate('Items (next)', request.locale),
'href': next_href
})
content['links'].append(
{