From 577a0f09e5aa0bee2774b4e74a2ac73d4da22073 Mon Sep 17 00:00:00 2001 From: pedro-cf Date: Sat, 4 May 2024 23:51:17 +0100 Subject: [PATCH 1/6] always generate links for all searches --- stac_fastapi/core/stac_fastapi/core/core.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stac_fastapi/core/stac_fastapi/core/core.py b/stac_fastapi/core/stac_fastapi/core/core.py index 053c8395..12c42a03 100644 --- a/stac_fastapi/core/stac_fastapi/core/core.py +++ b/stac_fastapi/core/stac_fastapi/core/core.py @@ -619,9 +619,7 @@ async def post_search( if maybe_count is not None: context_obj["matched"] = maybe_count - links = [] - if next_token: - links = await PagingLinks(request=request, next=next_token).get_links() + links = await PagingLinks(request=request, next=next_token).get_links() return ItemCollection( type="FeatureCollection", From e7deb47055592016445044fcbcb04797e6a125f0 Mon Sep 17 00:00:00 2001 From: pedro-cf Date: Sun, 5 May 2024 00:04:48 +0100 Subject: [PATCH 2/6] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bc23237..76793660 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- Fixed issue where searches return an empty `links` array [241](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/241) + ## [v2.4.0] From d646550e97a38a792953afacfe955e4ba08e15f4 Mon Sep 17 00:00:00 2001 From: pedro-cf Date: Sun, 5 May 2024 00:05:13 +0100 Subject: [PATCH 3/6] changelog --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76793660..a7759f53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed issue where searches return an empty `links` array [241](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/241) - ## [v2.4.0] ### Added From 5c439b513de108cb8714b6176c589fbb8fb88e4b Mon Sep 17 00:00:00 2001 From: pedro-cf Date: Sun, 5 May 2024 12:52:32 +0100 Subject: [PATCH 4/6] test --- stac_fastapi/tests/resources/test_item.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/stac_fastapi/tests/resources/test_item.py b/stac_fastapi/tests/resources/test_item.py index 20517f42..f84d9759 100644 --- a/stac_fastapi/tests/resources/test_item.py +++ b/stac_fastapi/tests/resources/test_item.py @@ -570,6 +570,15 @@ async def test_get_missing_item_collection(app_client): assert resp.status_code == 404 +@pytest.mark.asyncio +async def test_pagination_base_links(app_client, ctx): + """Test that a search query always contains basic links""" + page = await app_client.get(f"/collections/{ctx.item['collection']}/items") + + page_data = page.json() + assert {"self", "root"}.issubset({link["rel"] for link in page_data["links"]}) + + @pytest.mark.asyncio async def test_pagination_item_collection(app_client, ctx, txn_client): """Test item collection pagination links (paging extension)""" From db92423ef3f79d1dd80af87bf7623b1fe1a8278a Mon Sep 17 00:00:00 2001 From: pedro-cf Date: Sun, 5 May 2024 18:34:08 +0100 Subject: [PATCH 5/6] get_search fix --- stac_fastapi/core/stac_fastapi/core/core.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stac_fastapi/core/stac_fastapi/core/core.py b/stac_fastapi/core/stac_fastapi/core/core.py index 12c42a03..950a4f6f 100644 --- a/stac_fastapi/core/stac_fastapi/core/core.py +++ b/stac_fastapi/core/stac_fastapi/core/core.py @@ -318,9 +318,7 @@ async def item_collection( if maybe_count is not None: context_obj["matched"] = maybe_count - links = [] - if next_token: - links = await PagingLinks(request=request, next=next_token).get_links() + links = await PagingLinks(request=request, next=next_token).get_links() return ItemCollection( type="FeatureCollection", From bff015264d2bcb31a89bd6bc30bbb2a9666b8964 Mon Sep 17 00:00:00 2001 From: Jonathan Healy Date: Mon, 6 May 2024 11:52:10 +0800 Subject: [PATCH 6/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7759f53..46a95128 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed -- Fixed issue where searches return an empty `links` array [241](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/241) +- Fixed issue where searches return an empty `links` array [#241](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/241) ## [v2.4.0]