In this PR we remove trigger-letter-pdfs-for-day scheduled task and just call collate_letter_pdfs_for_day instead.

There was a datetime bug in the query which resulted in files not being sent to the postal provider.
The trigger-letter-pdfs-for-day task is no longer needed, so rather than fix the query just call collate_letter_pdfs_for_day directly.
Less code is always better.

Deployment considerations: I realized this is strictly not backwards compatible if the scheduled job is in progress and a task is on the queue that no longer exists. This is ok since we will deploy this well before 17:50.
This commit is contained in:
Rebecca Law
2018-09-12 17:16:34 +01:00
parent ae1ee85d12
commit f1b04193ca
7 changed files with 18 additions and 156 deletions

View File

@@ -105,7 +105,12 @@ def get_letters_pdf(template, contact_block, org_id, values):
@notify_celery.task(name='collate-letter-pdfs-for-day')
def collate_letter_pdfs_for_day(date):
def collate_letter_pdfs_for_day(date=None):
if not date:
# Using the truncated date is ok because UTC to BST does not make a difference to the date,
# since it is triggered mid afternoon.
date = datetime.utcnow().strftime("%Y-%m-%d")
letter_pdfs = s3.get_s3_bucket_objects(
current_app.config['LETTERS_PDF_BUCKET_NAME'],
subfolder=date

View File

@@ -1,5 +1,4 @@
from datetime import (
date,
datetime,
timedelta
)
@@ -32,7 +31,6 @@ from app.dao.notifications_dao import (
dao_timeout_notifications,
is_delivery_slow_for_provider,
delete_notifications_created_more_than_a_week_ago_by_type,
dao_get_count_of_letters_to_process_for_date,
dao_get_scheduled_notifications,
set_scheduled_notification_to_processed,
notifications_not_yet_sent
@@ -385,20 +383,6 @@ def run_letter_jobs():
current_app.logger.info("Queued {} ready letter job ids onto {}".format(len(job_ids), QueueNames.PROCESS_FTP))
@notify_celery.task(name="trigger-letter-pdfs-for-day")
@statsd(namespace="tasks")
def trigger_letter_pdfs_for_day():
letter_pdfs_count = dao_get_count_of_letters_to_process_for_date()
if letter_pdfs_count:
notify_celery.send_task(
name='collate-letter-pdfs-for-day',
args=(date.today().strftime("%Y-%m-%d"),),
queue=QueueNames.LETTERS
)
current_app.logger.info("{} letter pdfs to be process by {} task".format(
letter_pdfs_count, 'collate-letter-pdfs-for-day'))
@notify_celery.task(name='check-job-status')
@statsd(namespace="tasks")
def check_job_status():