If a job was created 7 days ago but scheduled to send 2 days later, the csv file will be deleted from S3 two days early.

For example if a file is uploaded on Aug 1, but scheduled for Aug 3, the csv file will be deleted 2 days before the notifications.
This will cause an error for on the jobs pages if the download report link is clicked.
This commit is contained in:
Rebecca Law
2019-08-07 16:54:04 +01:00
parent 328832f21f
commit 16fd12be6a
3 changed files with 21 additions and 3 deletions

View File

@@ -134,7 +134,7 @@ def dao_get_jobs_older_than_data_retention(notification_types):
end_date = today - timedelta(days=f.days_of_retention)
jobs.extend(Job.query.join(Template).filter(
Job.created_at < end_date,
func.coalesce(Job.scheduled_for, Job.created_at) < end_date,
Job.archived == False, # noqa
Template.template_type == f.notification_type,
Job.service_id == f.service_id
@@ -146,7 +146,7 @@ def dao_get_jobs_older_than_data_retention(notification_types):
x.service_id for x in flexible_data_retention if x.notification_type == notification_type
]
jobs.extend(Job.query.join(Template).filter(
Job.created_at < end_date,
func.coalesce(Job.scheduled_for, Job.created_at) < end_date,
Job.archived == False, # noqa
Template.template_type == notification_type,
Job.service_id.notin_(services_with_data_retention)