2016-11-15 15:56:29 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-03-08 19:16:11 +00:00
|
|
|
class PrecomputeFeedService < BaseService
|
2016-03-25 01:13:30 +00:00
|
|
|
# Fill up a user's home/mentions feed from DB and return a subset
|
2016-03-08 19:16:11 +00:00
|
|
|
# @param [Symbol] type :home or :mentions
|
|
|
|
# @param [Account] account
|
2017-04-02 14:46:31 +01:00
|
|
|
def call(_, account)
|
2017-04-04 12:58:34 +01:00
|
|
|
redis.pipelined do
|
|
|
|
Status.as_home_timeline(account).limit(FeedManager::MAX_ITEMS / 4).each do |status|
|
|
|
|
next if status.direct_visibility? || FeedManager.instance.filter?(:home, status, account)
|
|
|
|
redis.zadd(FeedManager.instance.key(:home, account.id), status.id, status.reblog? ? status.reblog_of_id : status.id)
|
|
|
|
end
|
2016-03-25 01:13:30 +00:00
|
|
|
end
|
2016-03-08 19:16:11 +00:00
|
|
|
end
|
|
|
|
|
2016-03-25 01:13:30 +00:00
|
|
|
private
|
2016-03-08 19:16:11 +00:00
|
|
|
|
|
|
|
def redis
|
2016-11-15 15:56:29 +00:00
|
|
|
Redis.current
|
2016-03-08 19:16:11 +00:00
|
|
|
end
|
|
|
|
end
|