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:
Chris Hill-Scott
2016-06-14 16:47:22 +01:00
parent 9eb777b867
commit 56d9c29e91
5 changed files with 46 additions and 6 deletions

View File

@@ -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]