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:
@@ -73,3 +73,15 @@ def clear_old_logs(older_than_days: int = 30):
|
||||
from services.database import clear_system_logs
|
||||
deleted = clear_system_logs(older_than_days)
|
||||
return {"deleted": deleted, "older_than_days": older_than_days}
|
||||
|
||||
|
||||
@router.delete("/purge-all")
|
||||
def purge_all_logs():
|
||||
"""Truncate the entire system_logs table."""
|
||||
from services.database import get_conn
|
||||
conn = get_conn()
|
||||
conn.execute("DELETE FROM system_logs")
|
||||
deleted = conn.total_changes
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return {"deleted": deleted}
|
||||
|
||||
Reference in New Issue
Block a user