This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2022-09-26 18:08:19 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Vacuum::FeedsVacuum
|
|
|
|
def perform
|
|
|
|
vacuum_inactive_home_feeds!
|
|
|
|
vacuum_inactive_list_feeds!
|
2022-10-02 08:33:37 -07:00
|
|
|
vacuum_inactive_direct_feeds!
|
2022-09-26 18:08:19 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def vacuum_inactive_home_feeds!
|
|
|
|
inactive_users.select(:id, :account_id).find_in_batches do |users|
|
|
|
|
feed_manager.clean_feeds!(:home, users.map(&:account_id))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def vacuum_inactive_list_feeds!
|
|
|
|
inactive_users_lists.select(:id).find_in_batches do |lists|
|
|
|
|
feed_manager.clean_feeds!(:list, lists.map(&:id))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-02 08:33:37 -07:00
|
|
|
def vacuum_inactive_direct_feeds!
|
|
|
|
inactive_users_lists.select(:id).find_in_batches do |lists|
|
|
|
|
feed_manager.clean_feeds!(:direct, lists.map(&:id))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-09-26 18:08:19 -07:00
|
|
|
def inactive_users
|
|
|
|
User.confirmed.inactive
|
|
|
|
end
|
|
|
|
|
|
|
|
def inactive_users_lists
|
|
|
|
List.where(account_id: inactive_users.select(:account_id))
|
|
|
|
end
|
|
|
|
|
|
|
|
def feed_manager
|
|
|
|
FeedManager.instance
|
|
|
|
end
|
|
|
|
end
|