mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Simplify failure rate by building separate query
This commit is contained in:
@@ -24,8 +24,7 @@ def format_statistics(statistics):
|
||||
def get_rate_of_permanent_failures_for_service(statistics, threshold=100):
|
||||
counts = {"permanent_failure": 0, "all_other_statuses": 0}
|
||||
for row in statistics:
|
||||
if row.notification_type == 'sms':
|
||||
_count_if_status_is_permanent_failure_from_row(counts, row)
|
||||
_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'])
|
||||
|
||||
Reference in New Issue
Block a user