2017-05-20 19:42:58 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Scheduler::FeedCleanupScheduler
|
|
|
|
include Sidekiq::Worker
|
2019-02-02 19:11:38 +01:00
|
|
|
include Redisable
|
2017-05-20 19:42:58 +02:00
|
|
|
|
2020-03-31 21:59:03 +02:00
|
|
|
sidekiq_options lock: :until_executed, retry: 0
|
2018-08-19 15:48:29 +02:00
|
|
|
|
2017-05-20 19:42:58 +02:00
|
|
|
def perform
|
2017-12-05 23:20:27 +01:00
|
|
|
clean_home_feeds!
|
|
|
|
clean_list_feeds!
|
2019-06-25 22:56:32 +02:00
|
|
|
clean_direct_feeds!
|
2017-12-05 23:20:27 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def clean_home_feeds!
|
2020-12-22 23:57:46 +01:00
|
|
|
feed_manager.clean_feeds!(:home, inactive_account_ids)
|
2017-12-05 23:20:27 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def clean_list_feeds!
|
2020-12-22 23:57:46 +01:00
|
|
|
feed_manager.clean_feeds!(:list, inactive_list_ids)
|
2017-12-05 23:20:27 +01:00
|
|
|
end
|
|
|
|
|
2019-06-25 22:56:32 +02:00
|
|
|
def clean_direct_feeds!
|
2020-12-23 01:47:45 +01:00
|
|
|
feed_manager.clean_feeds!(:direct, inactive_account_ids)
|
2017-05-20 19:42:58 +02:00
|
|
|
end
|
|
|
|
|
2017-12-05 23:20:27 +01:00
|
|
|
def inactive_account_ids
|
|
|
|
@inactive_account_ids ||= User.confirmed.inactive.pluck(:account_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def inactive_list_ids
|
|
|
|
List.where(account_id: inactive_account_ids).pluck(:id)
|
|
|
|
end
|
2017-05-20 19:42:58 +02:00
|
|
|
|
2017-12-05 23:20:27 +01:00
|
|
|
def feed_manager
|
|
|
|
FeedManager.instance
|
2017-05-20 19:42:58 +02:00
|
|
|
end
|
|
|
|
end
|