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