mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Use a ModelList for lists of jobs
This follows the pattern of what we’ve done with services, users and events. It gives us a way of neatly instantiating a model for each item in the list we get back from the API and reduces the complexity of the view layer code. Now is a good time to do this because we’re going to be making a bunch of changes to the jobs pages, and those changes will be easier to code and understand with a sensible model behind them.
This commit is contained in:
@@ -78,19 +78,3 @@ def statistics_by_state(statistics):
|
||||
'failed': statistics['emails_failed']
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def get_failure_rate_for_job(job):
|
||||
if not job.get('notifications_delivered'):
|
||||
return 1 if job.get('notifications_failed') else 0
|
||||
return (
|
||||
job.get('notifications_failed', 0) /
|
||||
(job.get('notifications_failed', 0) + job.get('notifications_delivered', 0))
|
||||
)
|
||||
|
||||
|
||||
def add_rate_to_job(job):
|
||||
return dict(
|
||||
failure_rate=(get_failure_rate_for_job(job)) * 100,
|
||||
**job
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user