Skip to content

Commit

Permalink
overlay settings
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Dec 23, 2024
1 parent 8aefc47 commit ab90bf8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
17 changes: 6 additions & 11 deletions pygeoapi/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
Returns content from plugins and sets responses.
"""

from collections import OrderedDict
from collections import ChainMap, OrderedDict
from copy import deepcopy
from datetime import datetime
from functools import partial
Expand Down Expand Up @@ -1604,16 +1604,11 @@ def evaluate_limit(requested: Union[None, int], server_limits: dict,
:returns: `int` of evaluated limit
"""

if collection_limits:
LOGGER.debug('Using collection defined limit')
max_ = collection_limits.get('maxitems', 10)
default = collection_limits.get('defaultitems', 10)
on_exceed = collection_limits.get('on_exceed', 'throttle')
else:
LOGGER.debug('Using server defined limit')
max_ = server_limits.get('maxitems', 10)
default = server_limits.get('defaultitems', 10)
on_exceed = server_limits.get('on_exceed', 'throttle')
effective_limits = ChainMap(collection_limits, server_limits)

default = effective_limits.get('defaultitems', 10)
max_ = effective_limits.get('maxitems', 10)
on_exceed = effective_limits.get('on_exceed', 'throttle')

LOGGER.debug(f'Requested limit: {requested}')
LOGGER.debug(f'Default limit: {default}')
Expand Down
6 changes: 6 additions & 0 deletions tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,3 +881,9 @@ def test_evaluate_limit():

with pytest.raises(RuntimeError):
assert evaluate_limit('40', server, collection) == 40

collection = {'defaultitems': 10}
server = {'defaultitems': 2, 'maxitems': 3}

assert evaluate_limit(None, server, collection) == 10
assert evaluate_limit('40', server, collection) == 3

0 comments on commit ab90bf8

Please sign in to comment.