You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
556 B

  1. # frozen_string_literal: true
  2. class Scheduler::PreviewCardsCleanupScheduler
  3. include Sidekiq::Worker
  4. sidekiq_options unique: :until_executed, retry: 0
  5. def perform
  6. Maintenance::UncachePreviewWorker.push_bulk(recent_link_preview_cards.pluck(:id))
  7. Maintenance::UncachePreviewWorker.push_bulk(older_preview_cards.pluck(:id))
  8. end
  9. private
  10. def recent_link_preview_cards
  11. PreviewCard.where(type: :link).where('updated_at < ?', 1.month.ago)
  12. end
  13. def older_preview_cards
  14. PreviewCard.where('updated_at < ?', 6.months.ago)
  15. end
  16. end