demarches-normaliennes/app/jobs/purge_unattached_blobs_job.rb

10 lines
229 B
Ruby
Raw Normal View History

2019-05-21 11:42:21 +02:00
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