2017-11-18 08:16:48 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class HomeFeed < Feed
|
|
|
|
def initialize(account)
|
|
|
|
@type = :home
|
|
|
|
@id = account.id
|
|
|
|
@account = account
|
|
|
|
end
|
|
|
|
|
2018-09-28 09:23:45 +09:00
|
|
|
def get(limit, max_id = nil, since_id = nil, min_id = nil)
|
2017-11-18 08:16:48 +09:00
|
|
|
if redis.exists("account:#{@account.id}:regeneration")
|
2018-09-28 09:23:45 +09:00
|
|
|
from_database(limit, max_id, since_id, min_id)
|
2017-11-18 08:16:48 +09:00
|
|
|
else
|
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-09-28 09:23:45 +09:00
|
|
|
def from_database(limit, max_id, since_id, min_id)
|
2017-11-18 08:16:48 +09:00
|
|
|
Status.as_home_timeline(@account)
|
2018-09-28 09:23:45 +09:00
|
|
|
.paginate_by_id(limit, max_id: max_id, since_id: since_id, min_id: min_id)
|
2017-11-18 08:16:48 +09:00
|
|
|
.reject { |status| FeedManager.instance.filter?(:home, status, @account.id) }
|
|
|
|
end
|
|
|
|
end
|