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.

36 lines
657 B

  1. # frozen_string_literal: true
  2. class FeedInsertWorker
  3. include Sidekiq::Worker
  4. attr_reader :status, :follower
  5. def perform(status_id, follower_id)
  6. @status = Status.find_by(id: status_id)
  7. @follower = Account.find_by(id: follower_id)
  8. check_and_insert
  9. end
  10. private
  11. def check_and_insert
  12. if records_available?
  13. perform_push unless feed_filtered?
  14. else
  15. true
  16. end
  17. end
  18. def records_available?
  19. status.present? && follower.present?
  20. end
  21. def feed_filtered?
  22. FeedManager.instance.filter?(:home, status, follower.id)
  23. end
  24. def perform_push
  25. FeedManager.instance.push(:home, follower, status)
  26. end
  27. end