Use the new task wrapper methods rather than creating a task directly

This commit is contained in:
Martyn Inglis
2017-05-09 18:17:55 +01:00
parent f2a47044a4
commit caed193647
4 changed files with 145 additions and 36 deletions

View File

@@ -18,6 +18,8 @@ from app.dao.templates_dao import dao_get_template_by_id
from app.models import SMS_TYPE, KEY_TYPE_TEST, BRANDING_ORG, EMAIL_TYPE, NOTIFICATION_TECHNICAL_FAILURE, \
NOTIFICATION_SENT, NOTIFICATION_SENDING
from app.celery.statistics_tasks import record_initial_job_statistics, create_initial_notification_statistic_tasks
def send_sms_to_provider(notification):
service = notification.service
@@ -57,6 +59,8 @@ def send_sms_to_provider(notification):
notification.billable_units = template.fragment_count
update_notification(notification, provider, notification.international)
create_initial_notification_statistic_tasks(notification)
current_app.logger.info(
"SMS {} sent to provider {} at {}".format(notification.id, provider.get_name(), notification.sent_at)
)
@@ -107,6 +111,8 @@ def send_email_to_provider(notification):
notification.reference = reference
update_notification(notification, provider)
create_initial_notification_statistic_tasks(notification)
current_app.logger.info(
"Email {} sent to provider at {}".format(notification.id, notification.sent_at)
)

View File

@@ -13,7 +13,7 @@ from app.clients.email.aws_ses import get_aws_responses
from app.dao import (
notifications_dao
)
from app.celery.statistics_tasks import create_outcome_notification_statistic_tasks
from app.notifications.process_client_response import validate_callback_data
from app.notifications.utils import confirm_subscription
@@ -95,6 +95,9 @@ def process_ses_response():
datetime.utcnow(),
notification.sent_at
)
create_outcome_notification_statistic_tasks(notification)
return jsonify(
result="success", message="SES callback succeeded"
), 200