mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 08:48:24 -04:00
Refactor again
This commit is contained in:
@@ -45,28 +45,26 @@ class Job(JSONModel):
|
|||||||
def scheduled(self):
|
def scheduled(self):
|
||||||
return self.status == 'scheduled'
|
return self.status == 'scheduled'
|
||||||
|
|
||||||
@property
|
def _aggregate_statistics(self, *statuses):
|
||||||
def notifications_delivered(self):
|
|
||||||
return sum(
|
return sum(
|
||||||
outcome['count'] for outcome in self._dict['statistics']
|
outcome['count'] for outcome in self._dict['statistics']
|
||||||
if outcome['status'] in {'delivered', 'sent'}
|
if not statuses or outcome['status'] in statuses
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def notifications_delivered(self):
|
||||||
|
return self._aggregate_statistics('delivered', 'sent')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def notifications_failed(self):
|
def notifications_failed(self):
|
||||||
return sum(
|
return self._aggregate_statistics(
|
||||||
outcome['count'] for outcome in self._dict['statistics']
|
'failed', 'technical-failure', 'temporary-failure',
|
||||||
if outcome['status'] in {
|
'permanent-failure', 'cancelled',
|
||||||
'failed', 'technical-failure', 'temporary-failure',
|
|
||||||
'permanent-failure', 'cancelled',
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def notifications_requested(self):
|
def notifications_requested(self):
|
||||||
return sum(
|
return self._aggregate_statistics()
|
||||||
outcome['count'] for outcome in self._dict['statistics']
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def notifications_sent(self):
|
def notifications_sent(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user