Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -61,7 +61,38 @@ def get_sources():
|
|
| 61 |
conn.close()
|
| 62 |
return df["source"].dropna().tolist()
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
|
|
|
|
|
|
| 65 |
@app.get("/summary/daily-actions")
|
| 66 |
def daily_actions(
|
| 67 |
start_date: Optional[str] = None,
|
|
|
|
| 61 |
conn.close()
|
| 62 |
return df["source"].dropna().tolist()
|
| 63 |
|
| 64 |
+
@app.get("/summary/daily")
|
| 65 |
+
def get_daily_summary():
|
| 66 |
+
conn = get_connection()
|
| 67 |
+
|
| 68 |
+
query = """
|
| 69 |
+
SELECT
|
| 70 |
+
summary_date,
|
| 71 |
+
short_summary,
|
| 72 |
+
key_focus,
|
| 73 |
+
top_stories,
|
| 74 |
+
generated_at
|
| 75 |
+
FROM daily_summaries
|
| 76 |
+
ORDER BY summary_date DESC
|
| 77 |
+
LIMIT 1
|
| 78 |
+
"""
|
| 79 |
+
|
| 80 |
+
df = pd.read_sql_query(query, conn)
|
| 81 |
+
conn.close()
|
| 82 |
+
|
| 83 |
+
if df.empty:
|
| 84 |
+
return {}
|
| 85 |
+
|
| 86 |
+
row = df.iloc[0].to_dict()
|
| 87 |
+
|
| 88 |
+
if row.get("top_stories"):
|
| 89 |
+
try:
|
| 90 |
+
row["top_stories"] = json.loads(row["top_stories"])
|
| 91 |
+
except Exception:
|
| 92 |
+
pass
|
| 93 |
|
| 94 |
+
return row
|
| 95 |
+
|
| 96 |
@app.get("/summary/daily-actions")
|
| 97 |
def daily_actions(
|
| 98 |
start_date: Optional[str] = None,
|