Skip to content

Commit

Permalink
Error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
shahthepro committed Mar 15, 2024
1 parent b78e21f commit c87dd1b
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions eagleproject/notify/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit c87dd1b

Please sign in to comment.