mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 00:07:02 -04:00
Highlight failing jobs on the dashboard
> When we have jobs that have over 3% failure rates we should highlight > those so that peoples attention is drawn to deal with the failure. > > They would then go to the job view to see what the details are where > they could filter by failure, but that's a different story... > > This is just about calculating and highlighting those that need their > attention. — https://www.pivotaltracker.com/story/show/121206123 This commit: - calculates the failure rate for each job - makes jobs with a failure rate of > 3% go red on the dashboard
This commit is contained in:
@@ -69,3 +69,21 @@ def statistics_by_state(statistics):
|
||||
'failed': statistics['emails_failed']
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def get_failure_rate_for_job(job):
|
||||
if not job.get('notifications_delivered'):
|
||||
if job.get('notifications_failed'):
|
||||
return 1
|
||||
return 0
|
||||
return (
|
||||
job.get('notifications_failed', 0) /
|
||||
(job.get('notifications_failed', 0) + job.get('notifications_delivered', 0))
|
||||
)
|
||||
|
||||
|
||||
def add_rate_to_jobs(jobs):
|
||||
return [dict(
|
||||
**job,
|
||||
failure_rate=(get_failure_rate_for_job(job)) * 100
|
||||
) for job in jobs]
|
||||
|
||||
Reference in New Issue
Block a user