Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Enable to define a maximum value for the search limit #748

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

* Add `from_extensions()` method to `CollectionSearchExtension` and `CollectionSearchPostExtension` extensions to build the class based on a list of available extensions.
* Add `stac_fastapi_max_search_limit` member to `ApiSettings`, so that it can be used in `types.search.crop()` to clamp `limit` to the desired value.

## [3.0.1] - 2024-08-27

Expand Down
1 change: 1 addition & 0 deletions stac_fastapi/types/stac_fastapi/types/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ApiSettings(BaseSettings):
stac_fastapi_description: str = "stac-fastapi"
stac_fastapi_version: str = "0.1"
stac_fastapi_landing_id: str = "stac-fastapi"
stac_fastapi_max_search_limit: int = 10000

app_host: str = "0.0.0.0"
app_port: int = 8000
Expand Down
5 changes: 4 additions & 1 deletion stac_fastapi/types/stac_fastapi/types/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
from typing_extensions import Annotated

from stac_fastapi.types.rfc3339 import DateTimeType, str_to_interval
from stac_fastapi.types.config import ApiSettings


settings = ApiSettings()

def crop(v: PositiveInt) -> PositiveInt:
"""Crop value to 10,000."""
limit = 10_000
limit = settings.stac_fastapi_max_search_limit
if v > limit:
v = limit
return v
Expand Down
Loading