mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-09-30 02:26:53 +00:00
fix: deduplicate repeated LXC digest results
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user