Skip to content

Commit

Permalink
update from main
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Oct 14, 2024
2 parents d91d155 + 4321497 commit 4b43593
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

## [Unreleased]

- Fix Docker compose file, so example data can be loaded into database (author @zstatmanweil, https://github.com/stac-utils/stac-fastapi-pgstac/pull/142)
- Fix Docker compose file, so example data can be loaded into database (author @zstatmanweil, <https://github.com/stac-utils/stac-fastapi-pgstac/pull/142>)
- Handle `next` and `dev` tokens now returned as links from pgstac>=0.9.0 (author @zstatmanweil, https://github.com/stac-utils/stac-fastapi-pgstac/pull/140)
- Add collection search extension ([#139](https://github.com/stac-utils/stac-fastapi-pgstac/pull/139))
- keep `/search` and `/collections` extensions separate ([#158](https://github.com/stac-utils/stac-fastapi-pgstac/pull/158))
- Fix `filter` extension implementation in `CoreCrudClient`
- update `pypgstac` requirement to `>=0.8,<0.10`
- set `pypgstac==0.9.*` for test requirements
Expand Down
17 changes: 16 additions & 1 deletion stac_fastapi/pgstac/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@
"bulk_transactions": BulkTransactionExtension(client=BulkTransactionsClient()),
}

# some extensions are supported in combination with the collection search extension
collection_extensions_map = {
"query": QueryExtension(),
"sort": SortExtension(),
"fields": FieldsExtension(),
"filter": FilterExtension(client=FiltersClient()),
}

enabled_extensions = (
os.environ["ENABLED_EXTENSIONS"].split(",")
if "ENABLED_EXTENSIONS" in os.environ
Expand All @@ -70,10 +78,17 @@
)

collection_search_extension = (
CollectionSearchExtension.from_extensions(extensions)
CollectionSearchExtension.from_extensions(
[
extension
for key, extension in collection_extensions_map.items()
if key in enabled_extensions
]
)
if "collection_search" in enabled_extensions
else None
)

collections_get_request_model = (
collection_search_extension.GET if collection_search_extension else EmptyRequest
)
Expand Down
4 changes: 3 additions & 1 deletion tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,9 @@ async def get_collection(
get_request_model = create_get_request_model(extensions)

collection_search_extension = CollectionSearchExtension.from_extensions(
extensions=extensions
extensions=[
FieldsExtension(),
]
)

api = StacApi(
Expand Down
10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ def api_client(request, database):
]
collection_search_extension = CollectionSearchExtension.from_extensions(extensions)

collection_extensions = [
QueryExtension(),
SortExtension(),
FieldsExtension(),
FilterExtension(client=FiltersClient()),
]
collection_search_extension = CollectionSearchExtension.from_extensions(
collection_extensions
)

items_get_request_model = create_request_model(
model_name="ItemCollectionUri",
base_model=ItemCollectionUri,
Expand Down

0 comments on commit 4b43593

Please sign in to comment.