mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 08:21:13 -05:00
Query directly for services with high failure rate
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user