imports_vacuum.rb 425 B

123456789101112131415161718
  1. # frozen_string_literal: true
  2. class Vacuum::ImportsVacuum
  3. def perform
  4. clean_unconfirmed_imports!
  5. clean_old_imports!
  6. end
  7. private
  8. def clean_unconfirmed_imports!
  9. BulkImport.where(state: :unconfirmed).where('created_at <= ?', 10.minutes.ago).reorder(nil).in_batches.delete_all
  10. end
  11. def clean_old_imports!
  12. BulkImport.where('created_at <= ?', 1.week.ago).reorder(nil).in_batches.delete_all
  13. end
  14. end