From e2c89c6766fc33b3dbc537fa79e4898078ab5bba 2018-11-06 12:29:46 From: Marcin Lulek Date: 2018-11-06 12:29:46 Subject: [PATCH] events: do not fail when handling events for removed applications --- diff --git a/backend/src/appenlight/models/event.py b/backend/src/appenlight/models/event.py index 1d01edc..018ed01 100644 --- a/backend/src/appenlight/models/event.py +++ b/backend/src/appenlight/models/event.py @@ -114,6 +114,11 @@ class Event(Base, BaseModel): event_types = [Event.types['error_report_alert'], Event.types['slow_report_alert']] app = Resource.by_resource_id(self.resource_id) + # if app was deleted close instantly + if not app: + self.close() + return + if self.event_type in event_types: total = ReportStatService.count_by_type( self.event_type, self.resource_id, since_when)