From c87dd1bcb22d98696896557b3ddfab9b39843839 Mon Sep 17 00:00:00 2001 From: Shahul Hameed <10547529+shahthepro@users.noreply.github.com> Date: Fri, 15 Mar 2024 13:30:09 +0530 Subject: [PATCH] Error handling --- eagleproject/notify/events/__init__.py | 28 +++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/eagleproject/notify/events/__init__.py b/eagleproject/notify/events/__init__.py index 274aa03..3afbdfb 100644 --- a/eagleproject/notify/events/__init__.py +++ b/eagleproject/notify/events/__init__.py @@ -219,18 +219,22 @@ def seen_filter(events): events_parsed.append(event_hash) - _, created = EventSeen.objects.get_or_create( - event_hash=event_hash, - last_seen__gt=datetime.now(tz=timezone.utc) - ev.deduplicate_time_window, - defaults={ - 'event_hash': event_hash, - 'last_seen': datetime.now(tz=timezone.utc) - } - ) - - if not created: - # Do not send duplicate alert within the defined time window - continue + try: + _, created = EventSeen.objects.get_or_create( + event_hash=event_hash, + last_seen__gt=datetime.now(tz=timezone.utc) - ev.deduplicate_time_window, + defaults={ + 'event_hash': event_hash, + 'last_seen': datetime.now(tz=timezone.utc) + } + ) + + if not created: + # Do not send duplicate alert within the defined time window + continue + + except: + print("Failed to apply seen filter") filtered.append(ev)