Query directly for services with high failure rate

This commit is contained in:
Pea Tyczynska
2019-12-05 16:07:06 +00:00
parent b8de67ae54
commit 1b7b26bf24
8 changed files with 116 additions and 204 deletions

View File

@@ -21,18 +21,6 @@ def format_statistics(statistics):
return counts
def get_rate_of_permanent_failures_for_service(statistics, threshold=100):
counts = {"permanent_failure": 0, "all_other_statuses": 0}
for row in statistics:
_count_if_status_is_permanent_failure_from_row(counts, row)
if counts['permanent_failure'] + counts['all_other_statuses'] >= threshold:
rate = counts['permanent_failure'] / (counts['permanent_failure'] + counts['all_other_statuses'])
else:
rate = 0
return rate
def format_admin_stats(statistics):
counts = create_stats_dict()
@@ -106,13 +94,6 @@ def _update_statuses_from_row(update_dict, row):
update_dict['failed'] += row.count
def _count_if_status_is_permanent_failure_from_row(update_dict, row):
if row.status == 'permanent-failure':
update_dict['permanent_failure'] += row.count
else:
update_dict['all_other_statuses'] += row.count
def create_empty_monthly_notification_status_stats_dict(year):
utc_month_starts = get_months_for_financial_year(year)
# nested dicts - data[month][template type][status] = count