From 513489e7907ab2e0f2672258c60be618eb678a05 Mon Sep 17 00:00:00 2001 From: taguesokoudjou Date: Mon, 29 Jun 2026 19:59:31 +0200 Subject: [PATCH] fix(patents): await async person and co-author lookups after dev merge --- service/src/main/inse/patents/authors/logic.py | 8 ++++---- service/src/main/inse/patents/authors/profile.py | 8 ++++---- service/src/main/inse/patents/org/logic.py | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/service/src/main/inse/patents/authors/logic.py b/service/src/main/inse/patents/authors/logic.py index 55b1c4b4..07086c23 100644 --- a/service/src/main/inse/patents/authors/logic.py +++ b/service/src/main/inse/patents/authors/logic.py @@ -41,7 +41,7 @@ async def get_patents_by_author_id( search_client = client or PatentSearchClient() ipc_search_client = ipc_client or IpcSearchClient() - author = _get_author(author_id) + author = await _get_author(author_id) if not author: return model.PatentsByAuthorResponse( author_id=author_id, @@ -86,7 +86,7 @@ async def get_patents_by_author_id( all_patents = deduplicate_patents(all_patents) - profile = build_author_profile( + profile = await build_author_profile( author, patent_hit_count=patent_hit_count, ) @@ -141,7 +141,7 @@ def _filter_patents_by_last_name( ] -def _get_author(author_id: str) -> Author | None: +async def _get_author(author_id: str) -> Author | None: short_id = author_id.replace("https://openalex.org/", "") - result = person_logic.search_persons(author_id=short_id) + result = await person_logic.search_persons(author_id=short_id) return result.results[0] if result.results else None diff --git a/service/src/main/inse/patents/authors/profile.py b/service/src/main/inse/patents/authors/profile.py index 7c4ca646..93bd720f 100644 --- a/service/src/main/inse/patents/authors/profile.py +++ b/service/src/main/inse/patents/authors/profile.py @@ -93,7 +93,7 @@ def _author_topics(author: Author) -> list[AuthorTopic]: return topics[:15] -def _fetch_co_author_names(author_id: str, display_name: str) -> list[str]: +async def _fetch_co_author_names(author_id: str, display_name: str) -> list[str]: short_id = _normalize_author_id(author_id) author_url = f"https://openalex.org/{short_id}" normalized_self = display_name.casefold().strip() @@ -115,7 +115,7 @@ def _fetch_co_author_names(author_id: str, display_name: str) -> list[str]: } try: - response = elasticsearch.search( + response = await elasticsearch.search( index=config.settings.openalex_works_search_index, body=body, ) @@ -141,7 +141,7 @@ def _fetch_co_author_names(author_id: str, display_name: str) -> list[str]: return co_authors[:40] -def build_author_profile( +async def build_author_profile( author: Author, *, patent_hit_count: int | None = None, @@ -154,7 +154,7 @@ def build_author_profile( co_author_names: list[str] = [] if fetch_co_authors and author_id: - co_author_names = _fetch_co_author_names(author_id, display_name) + co_author_names = await _fetch_co_author_names(author_id, display_name) return AuthorProfile( author_id=author_id, diff --git a/service/src/main/inse/patents/org/logic.py b/service/src/main/inse/patents/org/logic.py index 44e8e2f0..f7b44677 100644 --- a/service/src/main/inse/patents/org/logic.py +++ b/service/src/main/inse/patents/org/logic.py @@ -315,7 +315,7 @@ async def _search_patents_by_author( patents = deduplicate_patents(patents) patent_hit_count = parse_search_total(epo_data) + parse_search_total(uspto_data) - profile = build_author_profile(author, patent_hit_count=patent_hit_count) + profile = await build_author_profile(author, patent_hit_count=patent_hit_count) matched_patents = disambiguate_patents(patents, profile) return [patent_from_matched(entry) for entry in matched_patents]