0
0
Fork 0

Add tootctl preview_cards remove (#11320)

* Add `tootctl preview_cards remove`

* fix code style

* Remove `Scheduler::PreviewCardsCleanupScheduler` file

* fix code style again
Add exclude case where image_file_name is blank

* Added a function to output confirmation if the specified number of days is less than 2 weeks
This commit is contained in:
mayaeh 2019-07-28 20:48:19 +09:00 committed by Eugen Rochko
parent 9349f1067a
commit 0d80f686d8
4 changed files with 98 additions and 25 deletions

View file

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