|
|
@ -2,17 +2,13 @@ class PrecomputeFeedService < BaseService |
|
|
|
# Fill up a user's home/mentions feed from DB and return a subset |
|
|
|
# Fill up a user's home/mentions feed from DB and return a subset |
|
|
|
# @param [Symbol] type :home or :mentions |
|
|
|
# @param [Symbol] type :home or :mentions |
|
|
|
# @param [Account] account |
|
|
|
# @param [Account] account |
|
|
|
# @return [Array] |
|
|
|
def call(type, account) |
|
|
|
def call(type, account, limit) |
|
|
|
|
|
|
|
instant_return = [] |
|
|
|
instant_return = [] |
|
|
|
|
|
|
|
|
|
|
|
Status.send("as_#{type}_timeline", account).order('id desc').limit(FeedManager::MAX_ITEMS).find_each do |status| |
|
|
|
Status.send("as_#{type}_timeline", account).limit(FeedManager::MAX_ITEMS).each do |status| |
|
|
|
next if FeedManager.instance.filter?(type, status, account) |
|
|
|
next if FeedManager.instance.filter?(type, status, account) |
|
|
|
redis.zadd(FeedManager.instance.key(type, account.id), status.id, status.id) |
|
|
|
redis.zadd(FeedManager.instance.key(type, account.id), status.id, status.reblog? ? status.reblog_of_id : status.id) |
|
|
|
instant_return << status unless instant_return.size > limit |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
instant_return |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
private |
|
|
|