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