Use a constant
This commit is contained in:
parent
6e42e3b1ec
commit
3b704cec7d
|
@ -1,22 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class HomeFeed < Feed
|
||||
def initialize(account)
|
||||
@type = :home
|
||||
@id = account.id
|
||||
@account = account
|
||||
end
|
||||
|
||||
def get(limit = 20, max_id = nil, since_id = nil, min_id = nil)
|
||||
ActiveRecord::Base.connected_to(role: :reading) do
|
||||
from_database(limit, max_id, since_id, min_id)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def from_database(limit, max_id, since_id, min_id)
|
||||
Status.find_by_sql([<<-SQL, { id: @id, limit: limit, min_id: min_id, max_id: max_id }])
|
||||
QUERY = <<-SQL
|
||||
with cte as
|
||||
(
|
||||
select
|
||||
|
@ -50,5 +35,17 @@ class HomeFeed < Feed
|
|||
cte.rn_dupe = 1 or cte.reblog_of_id is null
|
||||
order by so.created_at desc
|
||||
SQL
|
||||
|
||||
def initialize(account)
|
||||
@type = :home
|
||||
@id = account.id
|
||||
@account = account
|
||||
end
|
||||
|
||||
def get(limit = 20, max_id = nil, since_id = nil, min_id = nil)
|
||||
ActiveRecord::Base.connected_to(role: :reading) do
|
||||
Status.find_by_sql([QUERY, { id: @id, limit: limit, min_id: min_id, max_id: max_id }])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue