2016-03-09 04:16:11 +09:00
|
|
|
class PrecomputeFeedService < BaseService
|
2016-03-25 10:13:30 +09:00
|
|
|
# Fill up a user's home/mentions feed from DB and return a subset
|
2016-03-09 04:16:11 +09:00
|
|
|
# @param [Symbol] type :home or :mentions
|
|
|
|
# @param [Account] account
|
2016-11-08 10:08:32 +09:00
|
|
|
def call(type, account)
|
2016-03-25 10:13:30 +09:00
|
|
|
instant_return = []
|
2016-03-09 04:16:11 +09:00
|
|
|
|
2016-11-08 10:08:32 +09:00
|
|
|
Status.send("as_#{type}_timeline", account).limit(FeedManager::MAX_ITEMS).each do |status|
|
2016-10-04 00:11:54 +09:00
|
|
|
next if FeedManager.instance.filter?(type, status, account)
|
2016-11-08 10:08:32 +09:00
|
|
|
redis.zadd(FeedManager.instance.key(type, account.id), status.id, status.reblog? ? status.reblog_of_id : status.id)
|
2016-03-25 10:13:30 +09:00
|
|
|
end
|
2016-03-09 04:16:11 +09:00
|
|
|
end
|
|
|
|
|
2016-03-25 10:13:30 +09:00
|
|
|
private
|
2016-03-09 04:16:11 +09:00
|
|
|
|
|
|
|
def redis
|
|
|
|
$redis
|
|
|
|
end
|
|
|
|
end
|