From 5d81de93db7e6dffc84389a7458104bb80863d8f Mon Sep 17 00:00:00 2001 From: Chris Holden Date: Fri, 22 Nov 2024 10:07:28 -0500 Subject: [PATCH] fix: Update search limit to maximum to encompass <12k results without exceeding max offset of 10,000 (#46) --- lambdas/link_fetcher/handler.py | 2 +- lambdas/link_fetcher/tests/conftest.py | 2 +- .../link_fetcher/tests/test_link_fetcher_handler.py | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lambdas/link_fetcher/handler.py b/lambdas/link_fetcher/handler.py index 5ea8b74..b982135 100644 --- a/lambdas/link_fetcher/handler.py +++ b/lambdas/link_fetcher/handler.py @@ -300,7 +300,7 @@ def get_query_parameters(start: int, day: date) -> Mapping[str, Any]: "startDate": f"{oldest_acquisition_date.strftime('%Y-%m-%d')}T00:00:00Z", "sortParam": "published", "sortOrder": "desc", - "maxRecords": 100, + "maxRecords": 2000, # `start` is 0-based, but `index` is 1-based, so we must add 1 "index": start + 1, # Fix for issue #28, due to breaking change in the OpenSearch API diff --git a/lambdas/link_fetcher/tests/conftest.py b/lambdas/link_fetcher/tests/conftest.py index c82f936..688084b 100644 --- a/lambdas/link_fetcher/tests/conftest.py +++ b/lambdas/link_fetcher/tests/conftest.py @@ -167,7 +167,7 @@ def generate_mock_responses_for_one_day(mock_search_response): "&startDate=2019-12-02T00:00:00Z" "&sortParam=published" "&sortOrder=desc" - "&maxRecords=100" + "&maxRecords=2000" "&index={1}" "&exactCount=1" ) diff --git a/lambdas/link_fetcher/tests/test_link_fetcher_handler.py b/lambdas/link_fetcher/tests/test_link_fetcher_handler.py index 5b54ef2..e13dffb 100644 --- a/lambdas/link_fetcher/tests/test_link_fetcher_handler.py +++ b/lambdas/link_fetcher/tests/test_link_fetcher_handler.py @@ -47,7 +47,7 @@ def test_that_link_fetcher_handler_generates_correct_query_parameters(): "startDate": "2019-12-02T00:00:00Z", "sortParam": "published", "sortOrder": "desc", - "maxRecords": 100, + "maxRecords": 2000, # `start` is 0-based, but `index` is 1-based, so we must add 1 when # computing the page number from the `start` index. "index": 1, @@ -92,7 +92,7 @@ def test_that_link_fetcher_handler_gets_correct_query_results(mock_search_respon "&startDate=2019-12-02T00:00:00Z" "&sortParam=published" "&sortOrder=desc" - "&maxRecords=100" + "&maxRecords=2000" "&index=1" "&exactCount=1" ), @@ -124,7 +124,7 @@ def test_that_link_fetcher_handler_defaults_total_results_to_neg1_when_missing( "&startDate=2019-12-02T00:00:00Z" "&sortParam=published" "&sortOrder=desc" - "&maxRecords=100" + "&maxRecords=2000" "&index=1" "&exactCount=1" ), @@ -155,7 +155,7 @@ def test_that_link_fetcher_handler_defaults_total_results_to_neg1_when_null( "&startDate=2019-12-02T00:00:00Z" "&sortParam=published" "&sortOrder=desc" - "&maxRecords=100" + "&maxRecords=2000" "&index=1" "&exactCount=1" ), @@ -186,7 +186,7 @@ def test_that_link_fetcher_handler_gets_correct_query_results_when_no_imagery_le "&startDate=2019-12-02T00:00:00Z" "&sortParam=published" "&sortOrder=desc" - "&maxRecords=100" + "&maxRecords=2000" "&index=1" "&exactCount=1" ),