0
0
Fork 0

Fix notification requests from suspended accounts still being listed (#32354)

This commit is contained in:
Claire 2024-10-09 19:29:02 +02:00 committed by GitHub
parent 03dbebdfef
commit d9fbb071da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 8 deletions

View file

@ -62,6 +62,6 @@ class NotificationPolicy < ApplicationRecord
private
def pending_notification_requests
@pending_notification_requests ||= notification_requests.limit(MAX_MEANINGFUL_COUNT).pick(Arel.sql('count(*), coalesce(sum(notifications_count), 0)::bigint'))
@pending_notification_requests ||= notification_requests.without_suspended.limit(MAX_MEANINGFUL_COUNT).pick(Arel.sql('count(*), coalesce(sum(notifications_count), 0)::bigint'))
end
end

View file

@ -26,6 +26,8 @@ class NotificationRequest < ApplicationRecord
before_save :prepare_notifications_count
scope :without_suspended, -> { joins(:from_account).merge(Account.without_suspended) }
def self.preload_cache_collection(requests)
cached_statuses_by_id = yield(requests.filter_map(&:last_status)).index_by(&:id) # Call cache_collection in block