This commit is contained in:
Mateusz Gruszczyński
2026-05-06 23:10:53 +02:00
parent 98f155b53a
commit 2691442fc1
9 changed files with 351 additions and 366 deletions

View File

@@ -326,11 +326,9 @@ def cleanup_summary() -> dict:
"jobs_total": _table_count("jobs"),
"jobs_clearable": _table_count("jobs", "WHERE status NOT IN ('pending', 'running')"),
"smart_queue_history_total": _table_count("smart_queue_history"),
"automation_history_total": _table_count("automation_history"),
"retention_days": {
"jobs": JOBS_RETENTION_DAYS,
"smart_queue_history": SMART_QUEUE_HISTORY_RETENTION_DAYS,
"automation_history": AUTOMATION_HISTORY_RETENTION_DAYS,
},
"database": _db_size(),
}
@@ -733,16 +731,6 @@ def cleanup_smart_queue():
return ok({"deleted": deleted, "cleanup": cleanup_summary()})
@bp.post("/cleanup/automations")
def cleanup_automations():
from ..services import automation_rules
profile = preferences.active_profile()
if not profile:
return jsonify({"ok": False, "error": "No profile"}), 400
deleted = automation_rules.clear_history(profile["id"])
return ok({"deleted": deleted, "cleanup": cleanup_summary()})
@bp.post("/cleanup/all")
def cleanup_all():
deleted_jobs = clear_jobs()
@@ -753,10 +741,7 @@ def cleanup_all():
else:
cur = conn.execute("DELETE FROM smart_queue_history")
deleted_smart = int(cur.rowcount or 0)
from ..services import automation_rules
profile = preferences.active_profile()
deleted_automation = automation_rules.clear_history(profile["id"]) if profile else 0
return ok({"deleted": {"jobs": deleted_jobs, "smart_queue_history": deleted_smart, "automation_history": deleted_automation}, "cleanup": cleanup_summary()})
return ok({"deleted": {"jobs": deleted_jobs, "smart_queue_history": deleted_smart}, "cleanup": cleanup_summary()})
@bp.post("/jobs/<job_id>/cancel")
@@ -1067,32 +1052,6 @@ def automations_delete(rule_id: int):
return jsonify({'ok': False, 'error': str(exc)}), 400
@bp.delete('/automations/history/<int:history_id>')
def automations_history_delete(history_id: int):
from ..services import automation_rules
profile = preferences.active_profile()
if not profile:
return jsonify({'ok': False, 'error': 'No profile'}), 400
try:
deleted = automation_rules.delete_history_item(history_id, profile['id'])
return ok({'deleted': deleted, 'history': automation_rules.list_history(profile['id'])})
except Exception as exc:
return jsonify({'ok': False, 'error': str(exc)}), 400
@bp.delete('/automations/history')
def automations_history_clear():
from ..services import automation_rules
profile = preferences.active_profile()
if not profile:
return jsonify({'ok': False, 'error': 'No profile'}), 400
try:
deleted = automation_rules.clear_history(profile['id'])
return ok({'deleted': deleted, 'history': []})
except Exception as exc:
return jsonify({'ok': False, 'error': str(exc)}), 400
@bp.post('/automations/check')
def automations_check():
from ..services import automation_rules