demarches-normaliennes/app/jobs/cleanup_stale_exports_job.rb

11 lines
309 B
Ruby
Raw Normal View History

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