From 43e2f763b2f43b5bbcb3b80890ebc89b73545b3b Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 10 Nov 2023 07:47:38 -0500 Subject: [PATCH] Extract crutches_active_mentions from FeedManager (#27785) --- app/lib/feed_manager.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index 2ed1457841..4e645a11f6 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -551,7 +551,7 @@ class FeedManager def build_crutches(receiver_id, statuses) crutches = {} - crutches[:active_mentions] = Mention.active.where(status_id: statuses.flat_map { |s| [s.id, s.reblog_of_id] }.compact).pluck(:status_id, :account_id).each_with_object({}) { |(id, account_id), mapping| (mapping[id] ||= []).push(account_id) } + crutches[:active_mentions] = crutches_active_mentions(statuses) check_for_blocks = statuses.flat_map do |s| arr = crutches[:active_mentions][s.id] || [] @@ -578,4 +578,12 @@ class FeedManager crutches end + + def crutches_active_mentions(statuses) + Mention + .active + .where(status_id: statuses.flat_map { |status| [status.id, status.reblog_of_id] }.compact) + .pluck(:status_id, :account_id) + .each_with_object({}) { |(id, account_id), mapping| (mapping[id] ||= []).push(account_id) } + end end