Version 9b #1
|
|
@ -644,6 +644,16 @@ def get_stats(x_profile_id: Optional[str]=Header(default=None), session: dict=De
|
|||
# ── AI Insights ───────────────────────────────────────────────────────────────
|
||||
import httpx, json
|
||||
|
||||
@app.get("/api/insights")
|
||||
def get_all_insights(x_profile_id: Optional[str]=Header(default=None), session: dict=Depends(require_auth)):
|
||||
"""Get all AI insights for profile."""
|
||||
pid = get_pid(x_profile_id)
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
cur.execute("SELECT * FROM ai_insights WHERE profile_id=%s ORDER BY created DESC", (pid,))
|
||||
rows = cur.fetchall()
|
||||
return [r2d(r) for r in rows]
|
||||
|
||||
@app.get("/api/insights/latest")
|
||||
def get_latest_insights(x_profile_id: Optional[str]=Header(default=None), session: dict=Depends(require_auth)):
|
||||
"""Get latest AI insights across all scopes."""
|
||||
|
|
@ -664,6 +674,15 @@ def get_ai_insight(scope: str, x_profile_id: Optional[str]=Header(default=None),
|
|||
if not row: return None
|
||||
return r2d(row)
|
||||
|
||||
@app.delete("/api/insights/{insight_id}")
|
||||
def delete_insight_by_id(insight_id: str, x_profile_id: Optional[str]=Header(default=None), session: dict=Depends(require_auth)):
|
||||
"""Delete a specific insight by ID."""
|
||||
pid = get_pid(x_profile_id)
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
cur.execute("DELETE FROM ai_insights WHERE id=%s AND profile_id=%s", (insight_id, pid))
|
||||
return {"ok":True}
|
||||
|
||||
@app.delete("/api/ai/insights/{scope}")
|
||||
def delete_ai_insight(scope: str, x_profile_id: Optional[str]=Header(default=None), session: dict=Depends(require_auth)):
|
||||
pid = get_pid(x_profile_id)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user