From f833f57e457debf323ef240aa26d0a97fc48d3d4 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 21 May 2019 11:42:21 +0200 Subject: [PATCH] Add PurgeUnattachedBlobsJob --- README.md | 1 + app/jobs/purge_unattached_blobs_job.rb | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 app/jobs/purge_unattached_blobs_job.rb diff --git a/README.md b/README.md index ed501dad8..3590f6833 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ En local, un utilisateur de test est créé automatiquement, avec les identifian Administrateurs::ActivateBeforeExpirationJob.set(cron: "0 8 * * *").perform_later WarnExpiringDossiersJob.set(cron: "0 0 1 * *").perform_later GestionnaireEmailNotificationJob.set(cron: "0 10 * * 1,2,3,4,5,6").perform_later + PurgeUnattachedBlobsJob.set("0 0 * * *").perform_later ### Voir les emails envoyés en local diff --git a/app/jobs/purge_unattached_blobs_job.rb b/app/jobs/purge_unattached_blobs_job.rb new file mode 100644 index 000000000..fb5d5804e --- /dev/null +++ b/app/jobs/purge_unattached_blobs_job.rb @@ -0,0 +1,9 @@ +class PurgeUnattachedBlobsJob < ApplicationJob + queue_as :cron + + def perform(*args) + ActiveStorage::Blob.unattached + .where('active_storage_blobs.created_at < ?', 24.hours.ago) + .find_each(&:purge_later) + end +end