lazy_retention
This commit is contained in:
@@ -16,7 +16,6 @@ def operation_logs_list():
|
||||
profile = _active_profile_or_400()
|
||||
if not profile:
|
||||
return ok({"logs": [], "total": 0, "stats": {}, "settings": operation_logs.get_settings(0), "error": "No profile"})
|
||||
operation_logs.apply_retention(int(profile["id"]))
|
||||
data = operation_logs.list_logs(
|
||||
int(profile["id"]),
|
||||
limit=int(request.args.get("limit") or 200),
|
||||
@@ -25,11 +24,22 @@ def operation_logs_list():
|
||||
q=str(request.args.get("q") or "").strip(),
|
||||
hide_jobs=str(request.args.get("hide_jobs") or "").lower() in {"1", "true", "yes", "on"},
|
||||
)
|
||||
data["stats"] = operation_logs.stats(int(profile["id"]))
|
||||
data["settings"] = data["stats"].get("settings")
|
||||
data["settings"] = operation_logs.get_settings(int(profile["id"]))
|
||||
if str(request.args.get("stats") or "").lower() in {"1", "true", "yes", "on"}:
|
||||
data["stats"] = operation_logs.stats(int(profile["id"]))
|
||||
data["settings"] = data["stats"].get("settings", data["settings"])
|
||||
return ok(data)
|
||||
|
||||
|
||||
@bp.get("/operation-logs/stats")
|
||||
def operation_logs_stats():
|
||||
profile = _active_profile_or_400()
|
||||
if not profile:
|
||||
return ok({"stats": {}, "settings": operation_logs.get_settings(0), "error": "No profile"})
|
||||
stats = operation_logs.stats(int(profile["id"]))
|
||||
return ok({"stats": stats, "settings": stats.get("settings")})
|
||||
|
||||
|
||||
@bp.post("/operation-logs/settings")
|
||||
def operation_logs_settings_save():
|
||||
profile = _active_profile_or_400()
|
||||
@@ -37,8 +47,7 @@ def operation_logs_settings_save():
|
||||
return jsonify({"ok": False, "error": "No profile"}), 400
|
||||
try:
|
||||
settings = operation_logs.save_settings(int(profile["id"]), request.get_json(silent=True) or {})
|
||||
result = operation_logs.apply_retention(int(profile["id"]))
|
||||
return ok({"settings": settings, "retention": result})
|
||||
return ok({"settings": settings})
|
||||
except Exception as exc:
|
||||
return jsonify({"ok": False, "error": str(exc)}), 403 if isinstance(exc, PermissionError) else 400
|
||||
|
||||
@@ -57,4 +66,5 @@ def operation_logs_apply_retention():
|
||||
profile = _active_profile_or_400()
|
||||
if not profile:
|
||||
return jsonify({"ok": False, "error": "No profile"}), 400
|
||||
return ok(operation_logs.apply_retention(int(profile["id"])))
|
||||
category = str((request.get_json(silent=True) or {}).get("category") or "all").strip().lower()
|
||||
return ok(operation_logs.apply_retention(int(profile["id"]), category=category))
|
||||
|
||||
Reference in New Issue
Block a user