From 5f939abfbe3bb48933c609875cf2b3f8569eb11d Mon Sep 17 00:00:00 2001 From: azuregc7 Date: Thu, 4 Feb 2021 12:02:51 -0800 Subject: [PATCH] [home] Home feed optimizations, sorting --- app/models/home_feed.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/home_feed.rb b/app/models/home_feed.rb index b210f58b..cde19609 100644 --- a/app/models/home_feed.rb +++ b/app/models/home_feed.rb @@ -39,18 +39,18 @@ class HomeFeed < Feed and not exists(select mm.target_account_id from mutes mm where mm.account_id = #{@id} and mm.target_account_id in (s.account_id, r.account_id)) and not exists(select bb.target_account_id from blocks bb where bb.account_id = #{@id} and bb.target_account_id in (s.account_id, r.account_id)) #{pagination_max} - #{pagination_min} - order by s.created_at desc + #{pagination_min} + order by s.id desc limit #{limit} ) sid - inner join statuses s on sid.id = s.id ) select - s.* + so.* from cte - inner join statuses s on cte.id = s.id + inner join statuses so on cte.id = so.id where - (cte.rn_dupe = 1 or cte.reblog_of_id is null) + cte.rn_dupe = 1 or cte.reblog_of_id is null + order by so.created_at desc " end end