demarches-normaliennes/app/jobs/purge_unattached_blobs_job.rb
2020-03-31 12:25:46 +02:00

9 lines
242 B
Ruby

class PurgeUnattachedBlobsJob < CronJob
self.cron_expression = "0 0 * * *"
def perform(*args)
ActiveStorage::Blob.unattached
.where('active_storage_blobs.created_at < ?', 24.hours.ago)
.find_each(&:purge_later)
end
end