Use the notification types enum for the notifications.notification_type.

Reuse EMAIL_TYPE in template_types and notification_types.
This commit is contained in:
Rebecca Law
2016-06-29 11:50:54 +01:00
parent 60e159e3c0
commit 25db1bce74
6 changed files with 35 additions and 27 deletions

View File

@@ -18,8 +18,8 @@ from app.models import (
Job,
NotificationStatistics,
TemplateStatistics,
TEMPLATE_TYPE_SMS,
TEMPLATE_TYPE_EMAIL,
SMS_TYPE,
EMAIL_TYPE,
Template,
ProviderStatistics,
ProviderDetails)
@@ -166,8 +166,8 @@ def dao_create_notification(notification, notification_type):
stats = NotificationStatistics(
day=notification.created_at.date(),
service_id=notification.service_id,
sms_requested=1 if notification_type == TEMPLATE_TYPE_SMS else 0,
emails_requested=1 if notification_type == TEMPLATE_TYPE_EMAIL else 0
sms_requested=1 if notification_type == SMS_TYPE else 0,
emails_requested=1 if notification_type == EMAIL_TYPE else 0
)
db.session.add(stats)
@@ -187,12 +187,12 @@ def dao_create_notification(notification, notification_type):
def _update_notification_stats_query(notification_type, status):
mapping = {
TEMPLATE_TYPE_SMS: {
SMS_TYPE: {
STATISTICS_REQUESTED: NotificationStatistics.sms_requested,
STATISTICS_DELIVERED: NotificationStatistics.sms_delivered,
STATISTICS_FAILURE: NotificationStatistics.sms_failed
},
TEMPLATE_TYPE_EMAIL: {
EMAIL_TYPE: {
STATISTICS_REQUESTED: NotificationStatistics.emails_requested,
STATISTICS_DELIVERED: NotificationStatistics.emails_delivered,
STATISTICS_FAILURE: NotificationStatistics.emails_failed
@@ -294,7 +294,7 @@ def update_provider_stats(
provider = ProviderDetails.query.filter_by(identifier=provider_name).one()
def unit_count():
if notification_type == TEMPLATE_TYPE_EMAIL:
if notification_type == EMAIL_TYPE:
return 1
else:
if (content_char_count):