From 18c9785325a67c6dbb13f22e7084ebcfa918ca79 Mon Sep 17 00:00:00 2001 From: Farajollahi Date: Mon, 20 Jul 2026 23:59:08 +0200 Subject: [PATCH] change index --- service/src/main/inse/dashboard/service.py | 2 +- .../src/main/inse/dashboard/test_service.py | 48 ++++--------------- 2 files changed, 11 insertions(+), 39 deletions(-) diff --git a/service/src/main/inse/dashboard/service.py b/service/src/main/inse/dashboard/service.py index 39fbc8fb..dca250cc 100644 --- a/service/src/main/inse/dashboard/service.py +++ b/service/src/main/inse/dashboard/service.py @@ -859,7 +859,7 @@ async def _top_eu_project_publication_authors( return [] publication_response = await elasticsearch.search( - index=ESIndex.CORDIS_EU_PUBLICATIONS_WILDCARD, + index=ESIndex.CORDIS_EU_FP7_PUBLICATIONS, body={ "size": 10000, "_source": ["projectID", "doi", "qaProcessedDoi"], diff --git a/service/src/main/inse/dashboard/test_service.py b/service/src/main/inse/dashboard/test_service.py index e0553d25..93302fc2 100644 --- a/service/src/main/inse/dashboard/test_service.py +++ b/service/src/main/inse/dashboard/test_service.py @@ -208,15 +208,13 @@ async def test_top_authors_maps_works_patents_news_and_eu_projects(): "author": { "id": "https://openalex.org/A2", "display_name": "Grace Example", - }, - "institutions": [{"id": ORG_INSTITUTION_ID}], + } }, { "author": { "id": "https://openalex.org/A1", "display_name": "Ada Example", - }, - "institutions": [{"id": ORG_INSTITUTION_ID}], + } }, ], } @@ -229,8 +227,7 @@ async def test_top_authors_maps_works_patents_news_and_eu_projects(): "author": { "id": "https://openalex.org/A2", "display_name": "Grace Example", - }, - "institutions": [{"id": ORG_INSTITUTION_ID}], + } } ], } @@ -325,25 +322,14 @@ async def test_top_authors_maps_works_patents_news_and_eu_projects(): ] assert len(works_calls) == 1 works_body = works_calls[0].kwargs["body"] - assert works_body["query"]["bool"]["filter"][0]["terms"]["doi"] == [ + assert works_body["query"]["terms"]["doi"] == [ "https://doi.org/10.1234/p1", "https://doi.org/10.1234/p2", ] - assert works_body["query"]["bool"]["filter"][1] == { - "nested": { - "path": "authorships.institutions", - "query": { - "term": { - "authorships.institutions.id": ORG_INSTITUTION_ID, - } - }, - } - } assert works_body["_source"] == [ "doi", "authorships.author.id", "authorships.author.display_name", - "authorships.institutions.id", ] @@ -369,7 +355,7 @@ async def test_top_eu_project_authors_count_filtered_projects_by_stable_author_i } if kwargs["index"] == config.settings.openalex_works_search_index: - assert kwargs["body"]["query"]["bool"]["filter"][0]["terms"]["doi"] == [ + assert kwargs["body"]["query"]["terms"]["doi"] == [ "https://doi.org/10.1/p1-a", "https://doi.org/10.1/p1-b", "https://doi.org/10.1/p2", @@ -385,24 +371,13 @@ async def test_top_eu_project_authors_count_filtered_projects_by_stable_author_i "author": { "id": "https://openalex.org/A1", "display_name": "Ada Example", - }, - "institutions": [{"id": ORG_INSTITUTION_ID}], + } }, { "author": { "id": "https://openalex.org/A2", "display_name": "Grace Example", - }, - "institutions": [{"id": ORG_INSTITUTION_ID}], - }, - { - "author": { - "id": "https://openalex.org/A3", - "display_name": "External Author", - }, - "institutions": [ - {"id": "https://openalex.org/I999"} - ], + } }, ], } @@ -415,8 +390,7 @@ async def test_top_eu_project_authors_count_filtered_projects_by_stable_author_i "author": { "id": "https://openalex.org/A1", "display_name": "Ada Example", - }, - "institutions": [{"id": ORG_INSTITUTION_ID}], + } } ], } @@ -429,8 +403,7 @@ async def test_top_eu_project_authors_count_filtered_projects_by_stable_author_i "author": { "id": "https://openalex.org/A1", "display_name": "Ada Example", - }, - "institutions": [{"id": ORG_INSTITUTION_ID}], + } } ], } @@ -443,8 +416,7 @@ async def test_top_eu_project_authors_count_filtered_projects_by_stable_author_i "author": { "id": "https://openalex.org/A999", "display_name": "Outside Author", - }, - "institutions": [{"id": ORG_INSTITUTION_ID}], + } } ], }