0
0
Fork 0

Add periodic removal of older thumbnails for preview cards (#11304)

This commit is contained in:
Eugen Rochko 2019-07-15 07:50:14 +02:00 committed by GitHub
parent cecd0c3cb1
commit b3f44aa186
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 0 deletions

View file

@ -0,0 +1,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