mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-06-10 17:04:45 +02:00
feat: auto-cleanup stale fires — prune >7d unflagged + >30d tombstones hourly
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
376b0dbb2d
commit
862d2dce42
1 changed files with 16 additions and 0 deletions
|
|
@ -45,6 +45,21 @@ logger = logging.getLogger(__name__)
|
|||
WFIGS_BROADCAST_COOLDOWN_S = 28800
|
||||
|
||||
|
||||
_last_cleanup = 0
|
||||
|
||||
|
||||
def _cleanup_stale_fires(conn) -> None:
|
||||
global _last_cleanup
|
||||
now = int(time.time())
|
||||
if now - _last_cleanup < 3600:
|
||||
return
|
||||
_last_cleanup = now
|
||||
cutoff_stale = now - (7 * 24 * 3600)
|
||||
cutoff_tomb = now - (30 * 24 * 3600)
|
||||
conn.execute("DELETE FROM fires WHERE last_event_at < ? AND tombstoned_at IS NULL", (cutoff_stale,))
|
||||
conn.execute("DELETE FROM fires WHERE tombstoned_at IS NOT NULL AND tombstoned_at < ?", (cutoff_tomb,))
|
||||
|
||||
|
||||
def _now() -> int:
|
||||
return int(time.time())
|
||||
|
||||
|
|
@ -225,6 +240,7 @@ def handle_wfigs(normalized: dict, envelope: dict, subject: str,
|
|||
event_log_row_id=log_id)
|
||||
return wire
|
||||
|
||||
_cleanup_stale_fires(conn)
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue