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.

21 lines
652 B

  1. # frozen_string_literal: true
  2. class PrecomputeFeedService < BaseService
  3. # Fill up a user's home/mentions feed from DB and return a subset
  4. # @param [Symbol] type :home or :mentions
  5. # @param [Account] account
  6. def call(_, account)
  7. redis.pipelined do
  8. Status.as_home_timeline(account).limit(FeedManager::MAX_ITEMS / 4).each do |status|
  9. next if status.direct_visibility? || FeedManager.instance.filter?(:home, status, account.id)
  10. redis.zadd(FeedManager.instance.key(:home, account.id), status.id, status.reblog? ? status.reblog_of_id : status.id)
  11. end
  12. end
  13. end
  14. private
  15. def redis
  16. Redis.current
  17. end
  18. end