From 60dc9f2aef6b7b62bbb14fa257ba6254ad2e2a72 Mon Sep 17 00:00:00 2001 From: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com> Date: Fri, 5 Aug 2022 10:36:42 -0400 Subject: [PATCH] Revert "Fix related media endpoint (#808)" This reverts commit d7962f17e002dd68821efc2fcb86f7edfc2bcec6. --- api/catalog/api/controllers/elasticsearch/related.py | 10 +--------- api/catalog/api/controllers/elasticsearch/search.py | 2 +- api/test/audio_integration_test.py | 5 ----- api/test/image_integration_test.py | 5 ----- api/test/media_integration.py | 6 ------ 5 files changed, 2 insertions(+), 26 deletions(-) diff --git a/api/catalog/api/controllers/elasticsearch/related.py b/api/catalog/api/controllers/elasticsearch/related.py index eaae030b9..e3b0decc6 100644 --- a/api/catalog/api/controllers/elasticsearch/related.py +++ b/api/catalog/api/controllers/elasticsearch/related.py @@ -2,7 +2,6 @@ import logging from elasticsearch_dsl import Search -from elasticsearch_dsl.response import Hit from catalog.api.controllers.elasticsearch.utils import ( exclude_filtered_providers, @@ -52,16 +51,9 @@ def related_media(uuid, index, filter_dead): result_count, _ = get_result_and_page_count(response, results, page_size) - dumpable_results = ( - results.to_dict() - if isinstance(results, Hit) - else [r.to_dict() for r in results] - ) - logger.debug( "finished post processing and returning related " f"result_count={result_count} " - f"results={json.dumps(dumpable_results)}" + f"results={json.dumps(results)}" ) - return results, result_count diff --git a/api/catalog/api/controllers/elasticsearch/search.py b/api/catalog/api/controllers/elasticsearch/search.py index ded8c5b7f..d3e009c23 100644 --- a/api/catalog/api/controllers/elasticsearch/search.py +++ b/api/catalog/api/controllers/elasticsearch/search.py @@ -248,7 +248,7 @@ def perform_search( dumpable_results = ( results.to_dict() if isinstance(results, Hit) - else [r.to_dict() for r in results] + else list(map(lambda r: r.to_dict(), results)) ) logger.debug( diff --git a/api/test/audio_integration_test.py b/api/test/audio_integration_test.py index deea1353d..14e2e2f86 100644 --- a/api/test/audio_integration_test.py +++ b/api/test/audio_integration_test.py @@ -8,7 +8,6 @@ from test.media_integration import ( detail, license_filter_case_insensitivity, - related, report, search, search_all_excluded, @@ -123,7 +122,3 @@ def test_audio_uuid_validation(): uuid_validation("audio", "123456789123456789123456789123456789") uuid_validation("audio", "12345678-1234-5678-1234-1234567891234") uuid_validation("audio", "abcd") - - -def test_image_related(audio_fixture): - related(audio_fixture) diff --git a/api/test/image_integration_test.py b/api/test/image_integration_test.py index 1419df6bb..4984f0fc8 100644 --- a/api/test/image_integration_test.py +++ b/api/test/image_integration_test.py @@ -9,7 +9,6 @@ from test.media_integration import ( detail, license_filter_case_insensitivity, - related, report, search, search_all_excluded, @@ -140,7 +139,3 @@ def test_image_uuid_validation(): uuid_validation("images", "123456789123456789123456789123456789") uuid_validation("images", "12345678-1234-5678-1234-1234567891234") uuid_validation("images", "abcd") - - -def test_image_related(image_fixture): - related(image_fixture) diff --git a/api/test/media_integration.py b/api/test/media_integration.py index b3f8ec7c3..848f931d1 100644 --- a/api/test/media_integration.py +++ b/api/test/media_integration.py @@ -169,9 +169,3 @@ def license_filter_case_insensitivity(media_type): def uuid_validation(media_type, identifier): response = requests.get(f"{API_URL}/v1/{media_type}/{identifier}", verify=False) assert response.status_code == 404 - - -def related(fixture): - related_url = fixture["results"][0]["related_url"] - response = requests.get(related_url) - assert response.status_code == 200