You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
649 B

  1. # frozen_string_literal: true
  2. class Scheduler::FeedCleanupScheduler
  3. include Sidekiq::Worker
  4. include Redisable
  5. sidekiq_options retry: 0
  6. def perform
  7. clean_home_feeds!
  8. clean_list_feeds!
  9. end
  10. private
  11. def clean_home_feeds!
  12. feed_manager.clean_feeds!(:home, inactive_account_ids)
  13. end
  14. def clean_list_feeds!
  15. feed_manager.clean_feeds!(:list, inactive_list_ids)
  16. end
  17. def inactive_account_ids
  18. @inactive_account_ids ||= User.confirmed.inactive.pluck(:account_id)
  19. end
  20. def inactive_list_ids
  21. List.where(account_id: inactive_account_ids).pluck(:id)
  22. end
  23. def feed_manager
  24. FeedManager.instance
  25. end
  26. end