Class: PurgeExpiredUploadsWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/purge_expired_uploads_worker.rb

Instance Method Summary collapse

Instance Method Details

#performObject



6
7
8
9
10
11
12
13
14
15
# File 'app/workers/purge_expired_uploads_worker.rb', line 6

def perform
  cutoff = Date.current
  Upload.where('expiration_date IS NOT NULL AND expiration_date < ?', cutoff)
        .where(resource_id: nil)
        .find_each(batch_size: 200) do |upload|
    upload.destroy
  rescue StandardError => e
    ErrorReporting.error(e, message: 'Failed to purge expired upload', upload_id: upload.id)
  end
end