automatyzacje-comit1

This commit is contained in:
Mateusz Gruszczyński
2026-05-07 07:24:16 +02:00
parent 2691442fc1
commit 440b187c39
6 changed files with 128 additions and 25 deletions

View File

@@ -94,6 +94,14 @@ def list_history(profile_id: int, user_id: int | None = None, limit: int = 30) -
return conn.execute('SELECT * FROM automation_history WHERE user_id=? AND profile_id=? ORDER BY created_at DESC LIMIT ?', (user_id, profile_id, max(1, min(int(limit or 30), 100)))).fetchall()
def clear_history(profile_id: int, user_id: int | None = None) -> int:
user_id = user_id or default_user_id()
with connect() as conn:
# Note: Manual automation log cleanup is scoped to the active profile and current user.
cur = conn.execute('DELETE FROM automation_history WHERE user_id=? AND profile_id=?', (user_id, profile_id))
return int(cur.rowcount or 0)
def _condition_true(t: dict[str, Any], cond: dict[str, Any]) -> bool:
typ = str(cond.get('type') or '')
if typ == 'completed': return bool(int(t.get('complete') or 0))