Change job selection dao to take flexible retention into account

Also test deleting jobs with flexible data retention

Also update tests for default data retention following logic
change: dao_get_jobs_older_than_data_retention now counts
today at the start of the day, not at a time when function runs
and updated tests reflect that
This commit is contained in:
Pea Tyczynska
2018-11-19 17:09:27 +00:00
committed by Alexey Bezhan
parent 744389f557
commit be6f37069b
4 changed files with 108 additions and 29 deletions

View File

@@ -23,7 +23,7 @@ from app.dao.invited_org_user_dao import delete_org_invitations_created_more_tha
from app.dao.invited_user_dao import delete_invitations_created_more_than_two_days_ago
from app.dao.jobs_dao import (
dao_set_scheduled_jobs_to_pending,
dao_get_jobs_older_than_limited_by
dao_get_jobs_older_than_data_retention
)
from app.dao.jobs_dao import dao_update_job
from app.dao.notifications_dao import (
@@ -64,7 +64,7 @@ from app.v2.errors import JobIncompleteError
@notify_celery.task(name="remove_csv_files")
@statsd(namespace="tasks")
def remove_csv_files(job_types):
jobs = dao_get_jobs_older_than_limited_by(job_types=job_types)
jobs = dao_get_jobs_older_than_data_retention(notification_types=job_types)
for job in jobs:
s3.remove_job_from_s3(job.service_id, job.id)
current_app.logger.info("Job ID {} has been removed from s3.".format(job.id))
@@ -299,7 +299,7 @@ def delete_inbound_sms_older_than_seven_days():
@notify_celery.task(name="remove_transformed_dvla_files")
@statsd(namespace="tasks")
def remove_transformed_dvla_files():
jobs = dao_get_jobs_older_than_limited_by(job_types=[LETTER_TYPE])
jobs = dao_get_jobs_older_than_data_retention(notification_types=[LETTER_TYPE])
for job in jobs:
s3.remove_transformed_dvla_file(job.id)
current_app.logger.info("Transformed dvla file for job {} has been removed from s3.".format(job.id))