mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Requested, delivered, and failed messages on dash
Requested, delivered and failed are the three states stored in the notification statistics table. They are not discrete, eg a message can be counted in delivered and failed. `requested` is incremented *when a notification is created*, and has no chance of being incremented twice for the same notification. The template statistics are incremented *when a notification is created only*. Therefore the only way to make the numbers line up is to count: - messages sent as being `requested` - failure rate being `failed`/`requested` *not* `failed`/`failed`+`delivered`
This commit is contained in:
@@ -99,19 +99,14 @@ def add_rates_to(delivery_statistics):
|
||||
delivery_statistics
|
||||
)
|
||||
|
||||
sum_of_statistics.update({
|
||||
'emails_sent': sum_of_statistics['emails_failed'] + sum_of_statistics['emails_delivered'],
|
||||
'sms_sent': sum_of_statistics['sms_failed'] + sum_of_statistics['sms_delivered']
|
||||
})
|
||||
|
||||
return dict(
|
||||
emails_failure_rate=(
|
||||
"{0:.1f}".format((float(sum_of_statistics['emails_failed']) / sum_of_statistics['emails_sent'] * 100))
|
||||
if sum_of_statistics.get('emails_sent') else 0
|
||||
"{0:.1f}".format((float(sum_of_statistics['emails_failed']) / sum_of_statistics['emails_requested'] * 100))
|
||||
if sum_of_statistics['emails_requested'] else 0
|
||||
),
|
||||
sms_failure_rate=(
|
||||
"{0:.1f}".format((float(sum_of_statistics['sms_failed']) / sum_of_statistics['sms_sent'] * 100))
|
||||
if sum_of_statistics.get('sms_sent') else 0
|
||||
"{0:.1f}".format((float(sum_of_statistics['sms_failed']) / sum_of_statistics['sms_requested'] * 100))
|
||||
if sum_of_statistics['sms_requested'] else 0
|
||||
),
|
||||
**sum_of_statistics
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user