Call the task wrapper outcome function in the statistics_tasks file. This wraps the logic around which tasks to creates and simplifies the logic in the Callback classes.

This commit is contained in:
Martyn Inglis
2017-05-09 22:03:57 +01:00
parent a4549a2e26
commit 19c14982a2
3 changed files with 57 additions and 12 deletions

View File

@@ -7,6 +7,8 @@ from app import statsd_client
from app.dao import notifications_dao
from app.clients.sms.firetext import get_firetext_responses
from app.clients.sms.mmg import get_mmg_responses
from app.celery.statistics_tasks import create_outcome_notification_statistic_tasks
sms_response_mapper = {
'MMG': get_mmg_responses,
@@ -45,8 +47,9 @@ def process_sms_client_response(status, reference, client_name):
# validate status
try:
response_dict = response_parser(status)
current_app.logger.info('{} callback return status of {} for reference: {}'.format(client_name,
status, reference))
current_app.logger.info('{} callback return status of {} for reference: {}'.format(
client_name, status, reference)
)
except KeyError:
msg = "{} callback failed: status {} not found.".format(client_name, status)
return success, msg
@@ -77,5 +80,8 @@ def process_sms_client_response(status, reference, client_name):
datetime.utcnow(),
notification.sent_at
)
create_outcome_notification_statistic_tasks(notification)
success = "{} callback succeeded. reference {} updated".format(client_name, reference)
return success, errors