From bb5354c1941374372c7eb857f93fcb140c912358 Mon Sep 17 00:00:00 2001 From: Mackenzie Grimes - NOAA Affiliate Date: Fri, 19 Sep 2025 13:49:00 -0600 Subject: [PATCH 1/2] support "includeInactive" query param to return even profiles marked inactive --- python/nwsc_proxy/ncp_web_service.py | 11 +++++++++-- python/nwsc_proxy/src/profile_store.py | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/python/nwsc_proxy/ncp_web_service.py b/python/nwsc_proxy/ncp_web_service.py index f44dcde..7444a91 100644 --- a/python/nwsc_proxy/ncp_web_service.py +++ b/python/nwsc_proxy/ncp_web_service.py @@ -64,11 +64,18 @@ def handler(self): # otherwise, must be 'GET' operation data_source = request.args.get("dataSource", None, type=str) profile_status = request.args.get("status", default="existing", type=str) + + # let request control if `isLive: false` profiles are included in response. + # Default to False if param not present (only return profiles where isLive: true) + include_inactive = request.args.get("includeInactive", default=False, type=bool) + if profile_status == "existing": - profiles = self.profile_store.get_all(data_source) + profiles = self.profile_store.get_all(data_source, include_inactive=include_inactive) elif profile_status == "new": - profiles = self.profile_store.get_all(data_source, is_new=True) + profiles = self.profile_store.get_all( + data_source, is_new=True, include_inactive=include_inactive + ) # update ProfileStore to label all queried events as no longer "new"; # they've now been returned to IDSS Engine clients at least once current_app.logger.info("Got all new profiles: %s", profiles) diff --git a/python/nwsc_proxy/src/profile_store.py b/python/nwsc_proxy/src/profile_store.py index c2a62dd..c98ce46 100644 --- a/python/nwsc_proxy/src/profile_store.py +++ b/python/nwsc_proxy/src/profile_store.py @@ -141,7 +141,7 @@ def __init__(self, base_dir: str): self.profile_cache = existing_profiles + new_profiles - def get_all(self, data_source="ANY", is_new=False) -> list[dict]: + def get_all(self, data_source="ANY", is_new=False, include_inactive=False) -> list[dict]: """Get all Support Profile JSONs persisted in this API, filtering by status='new' (if Support Profile has never been returned in an API request before) or status='existing' otherwise. @@ -158,7 +158,7 @@ def get_all(self, data_source="ANY", is_new=False) -> list[dict]: # is new, if client requested new profiles, or is existing cached_profile.is_new == is_new # is "active", meaning no one has intentional disabled/deactivated it - and cached_profile.is_active + and (include_inactive or cached_profile.is_active) # the end_dt has not yet passed (or profile is never-ending) and datetime.now(UTC).timestamp() <= cached_profile.end_timestamp ) From c8ce07bfc577639f44f56d8d24a639683a4caaec Mon Sep 17 00:00:00 2001 From: Mackenzie Grimes - NOAA Affiliate Date: Fri, 19 Sep 2025 14:27:43 -0600 Subject: [PATCH 2/2] fix unit tests --- python/nwsc_proxy/test/test_ncp_web_service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/nwsc_proxy/test/test_ncp_web_service.py b/python/nwsc_proxy/test/test_ncp_web_service.py index 0216a75..99ac8b5 100644 --- a/python/nwsc_proxy/test/test_ncp_web_service.py +++ b/python/nwsc_proxy/test/test_ncp_web_service.py @@ -137,7 +137,7 @@ def test_get_existing_profiles(wrapper: AppWrapper, mock_request: Mock, mock_pro assert status_code == 200 assert response.json == {"profiles": example_profile_list, "errors": []} # filter_new_profiles not set - mock_profile_store.return_value.get_all.assert_called_with("NBM") + mock_profile_store.return_value.get_all.assert_called_with("NBM", include_inactive=False) def test_get_new_profiles(wrapper: AppWrapper, mock_request: Mock, mock_profile_store: Mock): @@ -153,7 +153,7 @@ def test_get_new_profiles(wrapper: AppWrapper, mock_request: Mock, mock_profile_ get_call_args = mock_profile_store.return_value.get_all.mock_calls # called with is_new set to True - assert get_call_args[0][1:] == (("NBM",), {"is_new": True}) + assert get_call_args[0][1:] == (("NBM",), {"is_new": True, "include_inactive": False}) # expect that we told ProfileStore to label this profile as not new mark_existing_call_args = mock_profile_store.return_value.mark_as_existing.mock_calls