fix: exclude resolved problems from new-in-24h metrics (0.9.7)

Dashboard and created_within_hours list only show open/acknowledged problems
created in the last 24 hours; closed items appear under resolved only.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-11 10:24:12 +10:00
parent 3f671b9899
commit fed21c536b
7 changed files with 45 additions and 7 deletions
+32
View File
@@ -119,6 +119,38 @@ def test_problems_created_within_hours(client, db_session, jwt_headers):
assert body["items"][0]["title"] == "recent"
def test_problems_created_within_hours_excludes_resolved(client, db_session, jwt_headers):
now = datetime.now(timezone.utc)
h = Host(
hostname="p-host2",
os_family="linux",
product="ssh-monitor",
last_seen_at=now,
)
db_session.add(h)
db_session.flush()
db_session.add(
Problem(
host_id=h.id,
title="closed recently",
summary="s",
severity="warning",
status="resolved",
rule_id="rule:test",
fingerprint="fp-closed-recent",
event_count=1,
last_seen_at=now,
created_at=now - timedelta(hours=1),
updated_at=now - timedelta(minutes=30),
)
)
db_session.commit()
r = client.get("/api/v1/problems?created_within_hours=24", headers=jwt_headers)
assert r.status_code == 200
assert r.json()["total"] == 0
def test_problems_resolved_within_hours(client, db_session, jwt_headers):
now = datetime.now(timezone.utc)
h = Host(