From cf8895957671082c7dce515a4ecdcbdfde26afb7 Mon Sep 17 00:00:00 2001 From: ThomasTaroni Date: Thu, 3 Jul 2025 23:33:12 +0200 Subject: [PATCH] Update query parameters and response handling in server.py Replaced hardcoded date values with environment variables for flexibility and added a new filter for newspapers. Enhanced response parsing by including facets for related persons and organizations. --- src/phoenix_technologies/smd/server.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/phoenix_technologies/smd/server.py b/src/phoenix_technologies/smd/server.py index c5bc19d..025a144 100644 --- a/src/phoenix_technologies/smd/server.py +++ b/src/phoenix_technologies/smd/server.py @@ -107,8 +107,14 @@ async def smd_research(search_query: str = "Bundesrat", date_from: str = "2024-0 { "field": "datetime", "value": [ - date_from, - date_to + os.getenv('SWISSDOX_DATEFROM', '2020-12-31T23:00:00.000Z'), + os.getenv('SWISSDOX_DATETO', '2023-12-31T22:59:00.000Z') + ] + }, + { + "field": "newspaper", + "value": [ + os.getenv('SWISSDOX_NEWSPAPER', 'NZZ') ] }, { @@ -134,6 +140,7 @@ async def smd_research(search_query: str = "Bundesrat", date_from: str = "2024-0 result = response.json() articles = result.get("data", []) + facets = result.get("facets", []) tasks = [] for article in articles: @@ -142,7 +149,8 @@ async def smd_research(search_query: str = "Bundesrat", date_from: str = "2024-0 tasks.append(smd_detail_article(article_id)) detailed_articles = await asyncio.gather(*tasks) return { - "original_result": result, + "related_persons": facets.get("persons", []), + "related_organizations": facets.get("persons", []), "detailed_articles": detailed_articles } else: