Skip to content
New issue

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

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

Already on GitHub? # to your account

Don't generate paging links if provider created them #1982

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions pygeoapi/api/itemtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,33 +545,34 @@ def get_collection_items(
'href': f'{uri}?f={F_HTML}{serialized_query_params}'
}])

if offset > 0:
prev = max(0, offset - limit)
content['links'].append(
{
'type': 'application/geo+json',
'rel': 'prev',
'title': l10n.translate('Items (prev)', request.locale),
'href': f'{uri}?offset={prev}{serialized_query_params}'
})

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
})
if 'next' not in [link['rel'] for link in content['links']]:
if offset > 0:
prev = max(0, offset - limit)
content['links'].append(
{
'type': 'application/geo+json',
'rel': 'prev',
'title': l10n.translate('Items (prev)', request.locale),
'href': f'{uri}?offset={prev}{serialized_query_params}'
})

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(
{
Expand Down