From 67aa0a620bf565f2c3580e64e3e759f3ab4f33f9 Mon Sep 17 00:00:00 2001 From: hrodmn Date: Tue, 8 Oct 2024 09:25:50 -0500 Subject: [PATCH 1/4] create separate list of collection search extensions --- stac_fastapi/pgstac/app.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/stac_fastapi/pgstac/app.py b/stac_fastapi/pgstac/app.py index 5e28cd09..9ba27e08 100644 --- a/stac_fastapi/pgstac/app.py +++ b/stac_fastapi/pgstac/app.py @@ -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 @@ -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 ) From 018176f08b978c60a59bcc2c1818b00eb44ca4b1 Mon Sep 17 00:00:00 2001 From: hrodmn Date: Tue, 8 Oct 2024 09:32:53 -0500 Subject: [PATCH 2/4] update changelog --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 9aebcfc4..d3f65c1d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ - Fix Docker compose file, so example data can be loaded into database (author @zstatmanweil, ) - Add collection search extension ([#139](https://github.com/stac-utils/stac-fastapi-pgstac/pull/139)) + - keep item- and collection-search extensions separate ([#158](https://github.com/stac-utils/stac-fastapi-pgstac/pull/158)) - Fix `filter` extension implementation in `CoreCrudClient` From 5f263c62e0cc996124d20eaa19970375e3b821a5 Mon Sep 17 00:00:00 2001 From: hrodmn Date: Tue, 8 Oct 2024 12:18:47 -0500 Subject: [PATCH 3/4] specify collection_extensions in conftest.py --- tests/conftest.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index fc63514f..e571cae6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -134,7 +134,16 @@ def api_client(request, database): FilterExtension(client=FiltersClient()), BulkTransactionExtension(client=BulkTransactionsClient()), ] - 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", From 0cd94874a67359a448ca40b57a00074f3e6c4262 Mon Sep 17 00:00:00 2001 From: vincentsarago Date: Wed, 9 Oct 2024 15:42:47 +0200 Subject: [PATCH 4/4] remove last warning --- CHANGES.md | 3 +-- tests/api/test_api.py | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d3f65c1d..ba739ac7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,8 +4,7 @@ - Fix Docker compose file, so example data can be loaded into database (author @zstatmanweil, ) - Add collection search extension ([#139](https://github.com/stac-utils/stac-fastapi-pgstac/pull/139)) - - keep item- and collection-search extensions separate ([#158](https://github.com/stac-utils/stac-fastapi-pgstac/pull/158)) - +- keep `/search` and `/collections` extensions separate ([#158](https://github.com/stac-utils/stac-fastapi-pgstac/pull/158)) - Fix `filter` extension implementation in `CoreCrudClient` ## [3.0.0] - 2024-08-02 diff --git a/tests/api/test_api.py b/tests/api/test_api.py index b135dce5..34c75f0e 100644 --- a/tests/api/test_api.py +++ b/tests/api/test_api.py @@ -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(