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.
This commit is contained in:
parent
e5a6c59f7a
commit
cf88959576
1 changed files with 11 additions and 3 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue