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