Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion neonwatch/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ class AuditEntry:
"DELETE FROM links WHERE at < ?",
"DELETE FROM links_latest WHERE at < ?",
"DELETE FROM analyses WHERE completed_at < ?",
"DELETE FROM notified WHERE at < ?",
# A live issue keeps its record however old, or a restart would send it again.
"DELETE FROM notified WHERE at < ? AND issue_id NOT IN "
"(SELECT id FROM issues WHERE state != 'resolved')",
)

#: Size-pruning tiers, each the oldest rows first: every history table merged in time order,
Expand Down
11 changes: 11 additions & 0 deletions neonwatch/store_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,17 @@ def test_a_notification_keeps_the_highest_rank_sent_and_the_latest_time(tmp_path
s.close()


def test_a_live_issue_keeps_its_notification_past_retention(tmp_path: Path) -> None:
s = Store(tmp_path / "store.sqlite3", config(max_age_s=100))
s.apply(issue_event(issue("open", updated_at=10)))
s.apply(issue_event(issue("done", state=IssueState.RESOLVED, updated_at=10)))
for issue_id in ("open", "done", "gone"):
s.note_notified(issue_id, 2, 10.0)
s.prune(now=1000)
assert s.notified() == {"open": (2, 10.0)} # resolved or no longer stored: forgotten
s.close()


def _fill(s: Store, n: int) -> None:
for t in range(n):
s.apply(obs_event("wide", {f"field{k}": float(t) for k in range(50)}, at=1000 + t))
Expand Down
Loading