fix: deduplicate repeated LXC digest results

This commit is contained in:
VAIO73
2026-09-17 14:48:52 +02:00
parent 63e72abb27
commit 603fb0e03a
2 changed files with 45 additions and 22 deletions
+26 -13
View File
@@ -1636,20 +1636,33 @@ class NotificationManager:
conn = sqlite3.connect(str(DB_PATH), timeout=10)
conn.execute('PRAGMA journal_mode=WAL')
conn.execute('PRAGMA busy_timeout=5000')
# Adjacent collectors can observe the same completed task. Only
# coalesce byte-for-byte identical rows, so a different version,
# source or result stays visible in the same digest.
# Adjacent collectors can observe one completed LXC update with
# different transport details (for example source or duration).
# The rendered title already identifies its LXC and result, so
# coalesce that narrowly. Other event types retain the stricter
# title-and-body comparison so distinct updates stay visible.
now = int(time.time())
duplicate = conn.execute(
'SELECT 1 FROM digest_pending '
'WHERE channel = ? AND event_type = ? AND event_group = ? '
'AND severity = ? AND title = ? AND body = ? AND ts >= ? '
'LIMIT 1',
(
ch_name, event_type, event_group, severity, title, body,
now - self._DIGEST_DUPLICATE_WINDOW,
),
).fetchone()
if event_type == 'lxc_update_applied':
duplicate = conn.execute(
'SELECT 1 FROM digest_pending '
'WHERE channel = ? AND event_type = ? AND event_group = ? '
'AND severity = ? AND title = ? AND ts >= ? LIMIT 1',
(
ch_name, event_type, event_group, severity, title,
now - self._DIGEST_DUPLICATE_WINDOW,
),
).fetchone()
else:
duplicate = conn.execute(
'SELECT 1 FROM digest_pending '
'WHERE channel = ? AND event_type = ? AND event_group = ? '
'AND severity = ? AND title = ? AND body = ? AND ts >= ? '
'LIMIT 1',
(
ch_name, event_type, event_group, severity, title, body,
now - self._DIGEST_DUPLICATE_WINDOW,
),
).fetchone()
if duplicate:
conn.close()
return