Spaces:
Running
Running
feat: refine search query and increase top stories limit to 6
Browse files
src/api/routes/top_stories.py
CHANGED
|
@@ -226,14 +226,14 @@ async def fetch_kafka_stories(n: int = 3) -> List[TopStory]:
|
|
| 226 |
|
| 227 |
# ββ DuckDuckGo: fetch N live stories βββββββββββββββββββββββββββββββββββββββββ
|
| 228 |
|
| 229 |
-
async def fetch_live_stories(n: int =
|
| 230 |
"""Fetch N live stories from DuckDuckGo using the dedicated adapter"""
|
| 231 |
if not adapter:
|
| 232 |
return []
|
| 233 |
|
| 234 |
try:
|
| 235 |
-
#
|
| 236 |
-
query = "Ethiopia news today"
|
| 237 |
results = await adapter.search(query)
|
| 238 |
|
| 239 |
stories = []
|
|
@@ -288,8 +288,8 @@ async def get_top_stories(
|
|
| 288 |
|
| 289 |
# Fetch both sources in parallel
|
| 290 |
kafka_stories, live_stories = await asyncio.gather(
|
| 291 |
-
fetch_kafka_stories(
|
| 292 |
-
fetch_live_stories(
|
| 293 |
)
|
| 294 |
|
| 295 |
# Merge and deduplicate
|
|
|
|
| 226 |
|
| 227 |
# ββ DuckDuckGo: fetch N live stories βββββββββββββββββββββββββββββββββββββββββ
|
| 228 |
|
| 229 |
+
async def fetch_live_stories(n: int = 6, adapter: DuckDuckGoAdapter = None) -> List[TopStory]:
|
| 230 |
"""Fetch N live stories from DuckDuckGo using the dedicated adapter"""
|
| 231 |
if not adapter:
|
| 232 |
return []
|
| 233 |
|
| 234 |
try:
|
| 235 |
+
# Focus on Ethiopia-related world-wide news
|
| 236 |
+
query = "Ethiopia related world-wide news today"
|
| 237 |
results = await adapter.search(query)
|
| 238 |
|
| 239 |
stories = []
|
|
|
|
| 288 |
|
| 289 |
# Fetch both sources in parallel
|
| 290 |
kafka_stories, live_stories = await asyncio.gather(
|
| 291 |
+
fetch_kafka_stories(4),
|
| 292 |
+
fetch_live_stories(6, adapter),
|
| 293 |
)
|
| 294 |
|
| 295 |
# Merge and deduplicate
|