|
@@ -184,7 +184,7 @@ async def get_event_summary(event_id: str, include_articles: bool = False):
|
|
|
ttl_hours=CLUSTERS_TTL_HOURS,
|
|
ttl_hours=CLUSTERS_TTL_HOURS,
|
|
|
)
|
|
)
|
|
|
if cached_summary:
|
|
if cached_summary:
|
|
|
- return {
|
|
|
|
|
|
|
+ out = {
|
|
|
"event_id": event_id,
|
|
"event_id": event_id,
|
|
|
"headline": cached_summary.get("headline"),
|
|
"headline": cached_summary.get("headline"),
|
|
|
"mergedSummary": cached_summary.get("mergedSummary"),
|
|
"mergedSummary": cached_summary.get("mergedSummary"),
|
|
@@ -192,6 +192,21 @@ async def get_event_summary(event_id: str, include_articles: bool = False):
|
|
|
"sources": cached_summary.get("sources", []),
|
|
"sources": cached_summary.get("sources", []),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if include_articles:
|
|
|
|
|
+ cluster = store.get_cluster_by_id(event_id)
|
|
|
|
|
+ arts = (cluster or {}).get("articles", []) or []
|
|
|
|
|
+ out["articles"] = [
|
|
|
|
|
+ {
|
|
|
|
|
+ "title": a.get("title"),
|
|
|
|
|
+ "url": a.get("url"),
|
|
|
|
|
+ "source": a.get("source"),
|
|
|
|
|
+ "timestamp": a.get("timestamp"),
|
|
|
|
|
+ }
|
|
|
|
|
+ for a in arts
|
|
|
|
|
+ if isinstance(a, dict)
|
|
|
|
|
+ ]
|
|
|
|
|
+ return out
|
|
|
|
|
+
|
|
|
cluster = store.get_cluster_by_id(event_id)
|
|
cluster = store.get_cluster_by_id(event_id)
|
|
|
if not cluster:
|
|
if not cluster:
|
|
|
return {
|
|
return {
|