mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-05 06:00:53 -04:00
@@ -408,7 +408,7 @@ def _query_for_billing_data(notification_type, start_date, end_date, service):
|
||||
func.count().label("notifications_sent"),
|
||||
)
|
||||
.filter(
|
||||
NotificationAllTimeView.status.in_(NotificationStatus.sent_emails),
|
||||
NotificationAllTimeView.status.in_(NotificationStatus.sent_email_types),
|
||||
NotificationAllTimeView.key_type.in_((KeyType.NORMAL, KeyType.TEAM)),
|
||||
NotificationAllTimeView.created_at >= start_date,
|
||||
NotificationAllTimeView.created_at < end_date,
|
||||
@@ -440,7 +440,9 @@ def _query_for_billing_data(notification_type, start_date, end_date, service):
|
||||
func.count().label("notifications_sent"),
|
||||
)
|
||||
.filter(
|
||||
NotificationAllTimeView.status.in_(NotificationStatus.billable_sms),
|
||||
NotificationAllTimeView.status.in_(
|
||||
NotificationStatus.billable_sms_types
|
||||
),
|
||||
NotificationAllTimeView.key_type.in_((KeyType.NORMAL, KeyType.TEAM)),
|
||||
NotificationAllTimeView.created_at >= start_date,
|
||||
NotificationAllTimeView.created_at < end_date,
|
||||
|
||||
@@ -155,7 +155,7 @@ def send_email_to_provider(notification):
|
||||
def update_notification_to_sending(notification, provider):
|
||||
notification.sent_at = datetime.utcnow()
|
||||
notification.sent_by = provider.name
|
||||
if notification.status not in NotificationStatus.completed:
|
||||
if notification.status not in NotificationStatus.completed_types:
|
||||
notification.status = NotificationStatus.SENDING
|
||||
|
||||
dao_update_notification(notification)
|
||||
|
||||
14
app/enums.py
14
app/enums.py
@@ -52,7 +52,7 @@ class NotificationStatus(Enum):
|
||||
VIRUS_SCAN_FAILED = "virus-scan-failed"
|
||||
|
||||
@property
|
||||
def failed(self) -> tuple["NotificationStatus", ...]:
|
||||
def failed_types(self) -> tuple["NotificationStatus", ...]:
|
||||
cls = type(self)
|
||||
return (
|
||||
cls.TECHNICAL_FAILURE,
|
||||
@@ -63,7 +63,7 @@ class NotificationStatus(Enum):
|
||||
)
|
||||
|
||||
@property
|
||||
def completed(self) -> tuple["NotificationStatus", ...]:
|
||||
def completed_types(self) -> tuple["NotificationStatus", ...]:
|
||||
cls = type(self)
|
||||
return (
|
||||
cls.SENT,
|
||||
@@ -76,12 +76,12 @@ class NotificationStatus(Enum):
|
||||
)
|
||||
|
||||
@property
|
||||
def success(self) -> tuple["NotificationStatus", ...]:
|
||||
def success_types(self) -> tuple["NotificationStatus", ...]:
|
||||
cls = type(self)
|
||||
return (cls.SENT, cls.DELIVERED)
|
||||
|
||||
@property
|
||||
def billable(self) -> tuple["NotificationStatus", ...]:
|
||||
def billable_types(self) -> tuple["NotificationStatus", ...]:
|
||||
cls = type(self)
|
||||
return (
|
||||
cls.SENDING,
|
||||
@@ -94,7 +94,7 @@ class NotificationStatus(Enum):
|
||||
)
|
||||
|
||||
@property
|
||||
def billable_sms(self) -> tuple["NotificationStatus", ...]:
|
||||
def billable_sms_types(self) -> tuple["NotificationStatus", ...]:
|
||||
cls = type(self)
|
||||
return (
|
||||
cls.SENDING,
|
||||
@@ -106,7 +106,7 @@ class NotificationStatus(Enum):
|
||||
)
|
||||
|
||||
@property
|
||||
def sent_emails(self) -> tuple["NotificationStatus", ...]:
|
||||
def sent_email_types(self) -> tuple["NotificationStatus", ...]:
|
||||
cls = type(self)
|
||||
return (
|
||||
cls.SENDING,
|
||||
@@ -116,7 +116,7 @@ class NotificationStatus(Enum):
|
||||
)
|
||||
|
||||
@property
|
||||
def non_billable(self) -> tuple["NotificationStatus", ...]:
|
||||
def non_billable_types(self) -> tuple["NotificationStatus", ...]:
|
||||
self._non_billable: tuple["NotificationStatus", ...]
|
||||
try:
|
||||
return self._non_billable
|
||||
|
||||
@@ -1581,7 +1581,7 @@ class Notification(db.Model):
|
||||
self._personalisation = encryption.encrypt(personalisation or {})
|
||||
|
||||
def completed_at(self):
|
||||
if self.status in NotificationStatus.completed:
|
||||
if self.status in NotificationStatus.completed_types:
|
||||
return self.updated_at.strftime(DATETIME_FORMAT)
|
||||
|
||||
return None
|
||||
@@ -1621,7 +1621,7 @@ class Notification(db.Model):
|
||||
|
||||
def _substitute_status_str(_status):
|
||||
return (
|
||||
NotificationStatus.failed
|
||||
NotificationStatus.failed_types
|
||||
if _status == NotificationStatus.FAILED
|
||||
else [_status]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user