feeds_vacuum.rb 698 B

12345678910111213141516171819202122232425262728293031323334
  1. # frozen_string_literal: true
  2. class Vacuum::FeedsVacuum
  3. def perform
  4. vacuum_inactive_home_feeds!
  5. vacuum_inactive_list_feeds!
  6. end
  7. private
  8. def vacuum_inactive_home_feeds!
  9. inactive_users.select(:id, :account_id).in_batches do |users|
  10. feed_manager.clean_feeds!(:home, users.pluck(:account_id))
  11. end
  12. end
  13. def vacuum_inactive_list_feeds!
  14. inactive_users_lists.select(:id).in_batches do |lists|
  15. feed_manager.clean_feeds!(:list, lists.ids)
  16. end
  17. end
  18. def inactive_users
  19. User.confirmed.inactive
  20. end
  21. def inactive_users_lists
  22. List.where(account_id: inactive_users.select(:account_id))
  23. end
  24. def feed_manager
  25. FeedManager.instance
  26. end
  27. end