feat: Data Management tab — purge endpoints for all major data stores

Backend — new DELETE /purge-all endpoints:
  - /api/logs/purge-all          → truncate system_logs (immediate, no 30d wait)
  - /api/reports/purge-all       → cycle_reports + ai_reports
  - /api/portfolio/purge-all     → portfolio + trade_entry_prices
  - /api/analytics/purge-all     → pattern_score_history, regime_clusters,
                                    pattern_embeddings, cycle_runs,
                                    macro_regime_history, geo_alert_history
  - /api/var/purge-all           → var_snapshots + pnl_snapshots
  - /api/pattern-lab/purge-all   → backtest_lab_runs

Frontend — Config.tsx: new 'Data Management' tab
  - PurgeButton component with inline double-confirm (click Purge → confirm)
  - Shows table names affected + row count deleted
  - 6 purge actions: Logs, AI Reports, Portfolio, Analytics, VaR, Pattern Lab

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OpenSquared
2026-06-22 18:25:01 +02:00
parent 303ecc2a3a
commit 66f6607568
7 changed files with 221 additions and 3 deletions

View File

@@ -100,3 +100,20 @@ def trigger_regime_detect(n_clusters: int = Query(default=4, ge=2, le=6)):
def pattern_embeddings_summary():
"""Liste des patterns avec embedding vectoriel disponible."""
return {"embeddings": get_all_pattern_embeddings_summary()}
@router.delete("/purge-all")
def purge_all_analytics():
"""Purge all analytics history: score history, regime clusters, embeddings, cycle runs."""
from services.database import get_conn
conn = get_conn()
conn.execute("DELETE FROM pattern_score_history")
conn.execute("DELETE FROM regime_clusters")
conn.execute("DELETE FROM pattern_embeddings")
conn.execute("DELETE FROM cycle_runs")
conn.execute("DELETE FROM macro_regime_history")
conn.execute("DELETE FROM geo_alert_history")
n = conn.total_changes
conn.commit()
conn.close()
return {"deleted": n}