Merge pull request #4424 from Keirua/feat/delete-old-export

Ajout d'un job de suppression des vieux exports
This commit is contained in:
Keirua 2019-10-22 15:50:49 +02:00 committed by GitHub
commit b95e864461
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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