From d39664b827c25b83d30a288163aa18b123c8e5c2 Mon Sep 17 00:00:00 2001 From: Fosco Marotto Date: Sat, 23 Jan 2021 23:23:55 -0500 Subject: [PATCH] [home] refactor the home timeline query --- app/models/home_feed.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/app/models/home_feed.rb b/app/models/home_feed.rb index 84f95641..a84ed0f9 100644 --- a/app/models/home_feed.rb +++ b/app/models/home_feed.rb @@ -28,18 +28,15 @@ class HomeFeed < Feed from statuses s left join statuses reblog on s.reblog_of_id = reblog.id + left join follows f + on s.account_id = f.target_account_id + and f.account_id = #{@id} where s.created_at > NOW() - INTERVAL '7 days' and s.reply is false and ( s.account_id = #{@id} - or s.account_id in ( - select ff.target_account_id - from follows ff - join accounts af - on ff.target_account_id = af.id - and af.updated_at > NOW() - INTERVAL '7 days' - where ff.account_id = #{@id}) + or f.id is not null ) and s.account_id not in (select target_account_id from mutes where account_id = #{@id}) and (reblog.id is null or reblog.account_id not in (select target_account_id from mutes where account_id = #{@id})) @@ -58,8 +55,5 @@ class HomeFeed < Feed # or rb.text like '%' || cf.phrase || '%') # where cf.id is null or st.account_id = #{@id} #" - # .reject { |status| FeedManager.instance.filter?(:home, status, @account.id) } - # Status.as_home_timeline(@account) - # .paginate_by_id(limit, max_id: max_id, since_id: since_id, min_id: min_id) end end