mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 02:41:14 -05:00
Cleaning up function a bit.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
@@ -87,21 +87,19 @@ def create_zeroed_stats_dicts():
|
|||||||
|
|
||||||
|
|
||||||
def _update_statuses_from_row(update_dict, row, total_notifications=None):
|
def _update_statuses_from_row(update_dict, row, total_notifications=None):
|
||||||
# Initialize pending_count to total_notifications
|
requested_count = 0
|
||||||
if total_notifications is not None:
|
delivered_count = 0
|
||||||
pending_count = total_notifications
|
failed_count = 0
|
||||||
|
|
||||||
# Update requested count
|
# Update requested count
|
||||||
if row.status != NotificationStatus.CANCELLED:
|
if row.status != NotificationStatus.CANCELLED:
|
||||||
update_dict[StatisticsType.REQUESTED] += row.count
|
update_dict[StatisticsType.REQUESTED] += row.count
|
||||||
if total_notifications is not None:
|
requested_count += row.count
|
||||||
pending_count -= row.count # Subtract from pending_count
|
|
||||||
|
|
||||||
# Update delivered count
|
# Update delivered count
|
||||||
if row.status in (NotificationStatus.DELIVERED, NotificationStatus.SENT):
|
if row.status in (NotificationStatus.DELIVERED, NotificationStatus.SENT):
|
||||||
update_dict[StatisticsType.DELIVERED] += row.count
|
update_dict[StatisticsType.DELIVERED] += row.count
|
||||||
if total_notifications is not None:
|
delivered_count += row.count
|
||||||
pending_count -= row.count # Subtract from pending_count
|
|
||||||
|
|
||||||
# Update failure count
|
# Update failure count
|
||||||
if row.status in (
|
if row.status in (
|
||||||
@@ -113,11 +111,11 @@ def _update_statuses_from_row(update_dict, row, total_notifications=None):
|
|||||||
NotificationStatus.VIRUS_SCAN_FAILED,
|
NotificationStatus.VIRUS_SCAN_FAILED,
|
||||||
):
|
):
|
||||||
update_dict[StatisticsType.FAILURE] += row.count
|
update_dict[StatisticsType.FAILURE] += row.count
|
||||||
if total_notifications is not None:
|
failed_count += row.count
|
||||||
pending_count -= row.count # Subtract from pending_count
|
|
||||||
|
|
||||||
if total_notifications is not None:
|
if total_notifications is not None:
|
||||||
# Update pending count directly
|
# Update pending count directly
|
||||||
|
pending_count = total_notifications - (requested_count + delivered_count + failed_count)
|
||||||
update_dict[StatisticsType.PENDING] = pending_count
|
update_dict[StatisticsType.PENDING] = pending_count
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user