Revert "Process SNS request triggered by a DVLA S3 update"

This commit is contained in:
Imdad Ahad
2017-05-12 17:21:07 +01:00
committed by GitHub
parent c1e41e7dc8
commit 7a10a91262
8 changed files with 44 additions and 240 deletions

View File

@@ -1,7 +1,6 @@
import random
from datetime import (datetime)
from collections import namedtuple
from flask import current_app
from notifications_utils.recipients import (
@@ -24,10 +23,7 @@ from app.dao.jobs_dao import (
all_notifications_are_created_for_job,
dao_get_all_notifications_for_job,
dao_update_job_status)
from app.dao.notifications_dao import (
get_notification_by_id,
dao_update_notifications_sent_to_dvla
)
from app.dao.notifications_dao import get_notification_by_id, dao_update_notifications_sent_to_dvla
from app.dao.provider_details_dao import get_current_provider
from app.dao.services_dao import dao_fetch_service_by_id, fetch_todays_total_message_count
from app.dao.templates_dao import dao_get_template_by_id
@@ -358,27 +354,3 @@ def get_template_class(template_type):
# since we don't need rendering capabilities (we only need to extract placeholders) both email and letter can
# use the same base template
return WithSubjectTemplate
@notify_celery.task(bind=True, name='update-letter-notifications-statuses')
@statsd(namespace="tasks")
def update_letter_notifications_statuses(self, filename):
bucket_location = '{}-ftp'.format(current_app.config['NOTIFY_EMAIL_DOMAIN'])
response_file = s3.get_s3_object(bucket_location, filename).decode('utf-8')
try:
NotificationUpdate = namedtuple('NotificationUpdate', ['reference', 'status', 'page_count', 'cost_threshold'])
notification_updates = [NotificationUpdate(*line.split('|')) for line in response_file.splitlines()]
except TypeError:
current_app.logger.exception('DVLA response file: {} has an invalid format'.format(filename))
raise
else:
if notification_updates:
for update in notification_updates:
current_app.logger.info('DVLA update: {}'.format(str(update)))
# TODO: Update notifications with desired status
return notification_updates
else:
current_app.logger.exception('DVLA response file contained no updates')