Add task to remove transformed dvla files:

* Runs at 4:40am
* Remove files older than 7 days and only two day's worth
This commit is contained in:
Imdad Ahad
2017-06-07 16:31:51 +01:00
parent 1d30d93c6f
commit c4a89b77e3
3 changed files with 56 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ from app.dao.provider_details_dao import (
dao_toggle_sms_provider
)
from app.dao.users_dao import delete_codes_older_created_more_than_a_day_ago
from app.models import LETTER_TYPE
from app.notifications.process_notifications import send_notification_to_queue
from app.statsd_decorators import statsd
from app.celery.tasks import process_job
@@ -245,3 +246,12 @@ def delete_inbound_sms_older_than_seven_days():
except SQLAlchemyError as e:
current_app.logger.exception("Failed to delete inbound sms notifications")
raise
@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])
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))