mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-02 17:48:36 -04:00
set letter notifications to pending while notify-ftp does its stuff
this means that if the task is accidentally ran twice (eg we autoscale notify-celery-worker-beat to 2), it won't send letters twice. Additionally, update some function names and config variables to make it clear that they are referring to letter jobs, rather than all letter content
This commit is contained in:
@@ -28,7 +28,9 @@ from app.dao.notifications_dao import (
|
||||
is_delivery_slow_for_provider,
|
||||
delete_notifications_created_more_than_a_week_ago_by_type,
|
||||
dao_get_scheduled_notifications,
|
||||
set_scheduled_notification_to_processed)
|
||||
set_scheduled_notification_to_processed,
|
||||
dao_set_created_live_letter_api_notifications_to_pending,
|
||||
)
|
||||
from app.dao.statistics_dao import dao_timeout_job_statistics
|
||||
from app.dao.provider_details_dao import (
|
||||
get_current_provider,
|
||||
@@ -325,21 +327,28 @@ def run_letter_jobs():
|
||||
@notify_celery.task(name="run-letter-notifications")
|
||||
@statsd(namespace="tasks")
|
||||
def run_letter_notifications():
|
||||
notifications = dao_get_created_letter_api_notifications_that_dont_belong_to_jobs()
|
||||
current_time = datetime.utcnow().isoformat()
|
||||
|
||||
notifications = dao_set_created_live_letter_api_notifications_to_pending()
|
||||
|
||||
file_contents = create_dvla_file_contents_for_notifications(notifications)
|
||||
|
||||
file_location = '{}-dvla-notifications.txt'.format(current_time)
|
||||
s3upload(
|
||||
filedata=file_contents + '\n',
|
||||
region=current_app.config['AWS_REGION'],
|
||||
bucket_name=current_app.config['DVLA_UPLOAD_BUCKET_NAME'],
|
||||
file_location='2017-09-12-dvla-notifications.txt'
|
||||
bucket_name=current_app.config['DVLA_BUCKETS']['notification'],
|
||||
file_location=file_location
|
||||
)
|
||||
|
||||
# set noti statuses to pending or something
|
||||
|
||||
notify_celery.send_task(
|
||||
name=TaskNames.DVLA_NOTIFICATIONS,
|
||||
kwargs={'date': '2017-09-12'},
|
||||
kwargs={'filename': file_location},
|
||||
queue=QueueNames.PROCESS_FTP
|
||||
)
|
||||
current_app.logger.info("Queued {} ready letter job ids onto {}".format(len(notifications), QueueNames.PROCESS_FTP))
|
||||
current_app.logger.info(
|
||||
"Queued {} ready letter api notifications onto {}".format(
|
||||
len(notifications),
|
||||
QueueNames.PROCESS_FTP
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user