Skip to content

Commit

Permalink
fix: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren committed Dec 12, 2024
1 parent 142a705 commit 31ee8cd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions keep/api/alert_deduplicator/alert_deduplicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def _apply_deduplication_rule(
"alert_id": alert.id,
"fingerprint": alert.fingerprint,
"tenant_id": self.tenant_id,
"last_alert_hash_by_fingerprint": last_alert_hash_by_fingerprint,
},
)

Expand Down
4 changes: 2 additions & 2 deletions keep/api/core/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2110,7 +2110,7 @@ def get_all_deduplication_stats(tenant_id):
return stats


def get_last_alert_hash_by_fingerprint(tenant_id, fingerprint):
def get_last_alert_hash_by_fingerprint(tenant_id, fingerprint) -> str | None:
# get the last alert for a given fingerprint
# to check deduplication
with Session(engine) as session:
Expand All @@ -2121,7 +2121,7 @@ def get_last_alert_hash_by_fingerprint(tenant_id, fingerprint):
.limit(1)
)

alert_hash = session.exec(query).first()
alert_hash: str | None = session.scalars(query).first()
return alert_hash


Expand Down
2 changes: 1 addition & 1 deletion tests/test_deduplications.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ def test_custom_deduplication_rule(db_session, client, test_app):
assert custom_rule_found


@pytest.mark.timeout(20)
@pytest.mark.parametrize(
"test_app",
[
Expand Down Expand Up @@ -321,6 +320,7 @@ def test_custom_deduplication_rule_behaviour(db_session, client, test_app):
client.post(
"/alerts/event/datadog", json=alert, headers={"x-api-key": "some-api-key"}
)
time.sleep(0.3)

deduplication_rules = client.get(
"/deduplications", headers={"x-api-key": "some-api-key"}
Expand Down

0 comments on commit 31ee8cd

Please sign in to comment.