From ec78c99a2a2f81023ab31b0da900e929ab73c6a7 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Tue, 22 Oct 2019 15:18:40 +0200 Subject: [PATCH] ajout d'un job de suppression des vieux exports --- app/jobs/cleanup_stale_exports_job.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 app/jobs/cleanup_stale_exports_job.rb diff --git a/app/jobs/cleanup_stale_exports_job.rb b/app/jobs/cleanup_stale_exports_job.rb new file mode 100644 index 000000000..f00346124 --- /dev/null +++ b/app/jobs/cleanup_stale_exports_job.rb @@ -0,0 +1,10 @@ +class CleanupStaleExportsJob < ApplicationJob + queue_as :cron + + def perform(*args) + ActiveStorage::Attachment.where( + "name in ('csv_export_file', 'ods_export_file', 'xlsx_export_file') and created_at < ?", + Procedure::MAX_DUREE_CONSERVATION_EXPORT.ago + ).find_each(&:purge_later) + end +end