mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 16:38:59 -04:00
Use default dict for default job stats
This is just some refactoring. `defaultdict` is a data structure which won’t raise a `KeyError` if you try to access a key that doesn’t exist. By passing `int` as the first argument, trying to access the value of any key that doesn’t exists will return the value of `int()`, ie `0`
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from collections import defaultdict
|
||||
|
||||
from notifications_python_client.base import BaseAPIClient
|
||||
from app.notify_client import _attach_current_user
|
||||
@@ -16,12 +17,7 @@ class JobApiClient(BaseAPIClient):
|
||||
|
||||
@staticmethod
|
||||
def __convert_statistics(job):
|
||||
results = {
|
||||
'sending': 0,
|
||||
'delivered': 0,
|
||||
'failed': 0,
|
||||
'requested': 0
|
||||
}
|
||||
results = defaultdict(int)
|
||||
if 'statistics' in job:
|
||||
for outcome in job['statistics']:
|
||||
if outcome['status'] in ['failed', 'technical-failure', 'temporary-failure', 'permanent-failure']:
|
||||
|
||||
Reference in New Issue
Block a user