mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
Replaced "delivered".
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
@@ -170,22 +170,22 @@ def get_aws_responses(ses_message):
|
||||
"Permanent": {
|
||||
"message": "Hard bounced",
|
||||
"success": False,
|
||||
"notification_status": "permanent-failure",
|
||||
"notification_status": NotificationStatus.PERMANENT_FAILURE,
|
||||
},
|
||||
"Temporary": {
|
||||
"message": "Soft bounced",
|
||||
"success": False,
|
||||
"notification_status": "temporary-failure",
|
||||
"notification_status": NotificationStatus.TEMPORARY_FAILURE,
|
||||
},
|
||||
"Delivery": {
|
||||
"message": "Delivered",
|
||||
"success": True,
|
||||
"notification_status": "delivered",
|
||||
"notification_status": NotificationStatus.DELIVERED,
|
||||
},
|
||||
"Complaint": {
|
||||
"message": "Complaint",
|
||||
"success": True,
|
||||
"notification_status": "delivered",
|
||||
"notification_status": NotificationStatus.DELIVERED,
|
||||
},
|
||||
}[status]
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@ AWS_CLIENT_CONFIG = Config(
|
||||
},
|
||||
use_fips_endpoint=True,
|
||||
)
|
||||
STATISTICS_REQUESTED = "requested"
|
||||
STATISTICS_DELIVERED = "delivered"
|
||||
STATISTICS_FAILURE = "failure"
|
||||
|
||||
|
||||
class ClientException(Exception):
|
||||
|
||||
@@ -4,38 +4,39 @@ import botocore
|
||||
from boto3 import client
|
||||
from flask import current_app
|
||||
|
||||
from app.clients import AWS_CLIENT_CONFIG, STATISTICS_DELIVERED, STATISTICS_FAILURE
|
||||
from app.clients import AWS_CLIENT_CONFIG
|
||||
from app.clients.email import (
|
||||
EmailClient,
|
||||
EmailClientException,
|
||||
EmailClientNonRetryableException,
|
||||
)
|
||||
from app.cloudfoundry_config import cloud_config
|
||||
from app.enums import NotificationStatus, StatisticsType
|
||||
|
||||
ses_response_map = {
|
||||
"Permanent": {
|
||||
"message": "Hard bounced",
|
||||
"success": False,
|
||||
"notification_status": "permanent-failure",
|
||||
"notification_statistics_status": STATISTICS_FAILURE,
|
||||
"notification_status": NotificationStatus.PERMANENT_FAILURE,
|
||||
"notification_statistics_status": StatisticsType.FAILURE,
|
||||
},
|
||||
"Temporary": {
|
||||
"message": "Soft bounced",
|
||||
"success": False,
|
||||
"notification_status": "temporary-failure",
|
||||
"notification_statistics_status": STATISTICS_FAILURE,
|
||||
"notification_status": NotificationStatus.TEMPORARY_FAILURE,
|
||||
"notification_statistics_status": StatisticsType.FAILURE,
|
||||
},
|
||||
"Delivery": {
|
||||
"message": "Delivered",
|
||||
"success": True,
|
||||
"notification_status": "delivered",
|
||||
"notification_statistics_status": STATISTICS_DELIVERED,
|
||||
"notification_status": NotificationStatus.DELIVERED,
|
||||
"notification_statistics_status": StatisticsType.DELIVERED,
|
||||
},
|
||||
"Complaint": {
|
||||
"message": "Complaint",
|
||||
"success": True,
|
||||
"notification_status": "delivered",
|
||||
"notification_statistics_status": STATISTICS_DELIVERED,
|
||||
"notification_status": NotificationStatus.DELIVERED,
|
||||
"notification_statistics_status": StatisticsType.DELIVERED,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -209,3 +209,9 @@ class AgreementType(StrEnum):
|
||||
class AgreementStatus(StrEnum):
|
||||
ACTIVE = "active"
|
||||
EXPIRED = "expired"
|
||||
|
||||
|
||||
class StatisticsType(StrEnum):
|
||||
REQUESTED = "requested"
|
||||
DELIVERED = "delivered"
|
||||
FAILURE = "failure"
|
||||
|
||||
@@ -2,7 +2,7 @@ from collections import defaultdict
|
||||
from datetime import datetime
|
||||
|
||||
from app.dao.date_util import get_months_for_financial_year
|
||||
from app.enums import NotificationStatus, TemplateType
|
||||
from app.enums import NotificationStatus, StatisticsType, TemplateType
|
||||
|
||||
|
||||
def format_statistics(statistics):
|
||||
@@ -77,16 +77,16 @@ def format_monthly_template_notification_stats(year, rows):
|
||||
|
||||
def create_zeroed_stats_dicts():
|
||||
return {
|
||||
template_type: {status: 0 for status in ("requested", "delivered", "failed")}
|
||||
template_type: {status: 0 for status in StatisticsType}
|
||||
for template_type in (TemplateType.SMS, TemplateType.EMAIL)
|
||||
}
|
||||
|
||||
|
||||
def _update_statuses_from_row(update_dict, row):
|
||||
if row.status != NotificationStatus.CANCELLED:
|
||||
update_dict["requested"] += row.count
|
||||
update_dict[StatisticsType.REQUESTED] += row.count
|
||||
if row.status in (NotificationStatus.DELIVERED, NotificationStatus.SENT):
|
||||
update_dict["delivered"] += row.count
|
||||
update_dict[StatisticsType.DELIVERED] += row.count
|
||||
elif row.status in (
|
||||
NotificationStatus.FAILED,
|
||||
NotificationStatus.TECHNICAL_FAILURE,
|
||||
@@ -95,7 +95,7 @@ def _update_statuses_from_row(update_dict, row):
|
||||
NotificationStatus.VALIDATION_FAILED,
|
||||
NotificationStatus.VIRUS_SCAN_FAILED,
|
||||
):
|
||||
update_dict["failed"] += row.count
|
||||
update_dict[StatisticsType.FAILED] += row.count
|
||||
|
||||
|
||||
def create_empty_monthly_notification_status_stats_dict(year):
|
||||
|
||||
Reference in New Issue
Block a user