Merge remote-tracking branch 'parent/main' into upstream-20241015
This commit is contained in:
commit
ebdf1ecf49
24 changed files with 560 additions and 439 deletions
|
@ -70,7 +70,9 @@ class DomainBlock < ApplicationRecord
|
|||
reject_friend? ? :reject_friend : nil,
|
||||
block_trends? ? :block_trends : nil,
|
||||
detect_invalid_subscription? ? :detect_invalid_subscription : nil,
|
||||
reject_reports? ? :reject_reports : nil].reject { |policy| policy == :noop || policy.nil? }
|
||||
reject_reports? ? :reject_reports : nil]
|
||||
.reject { |policy| policy == :noop }
|
||||
.compact
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -18,5 +18,6 @@ class FollowRecommendation < ApplicationRecord
|
|||
belongs_to :account_summary, foreign_key: :account_id, inverse_of: false
|
||||
belongs_to :account
|
||||
|
||||
scope :localized, ->(locale) { joins(:account_summary).merge(AccountSummary.localized(locale)) }
|
||||
scope :unsupressed, -> { where.not(FollowRecommendationSuppression.where(FollowRecommendationSuppression.arel_table[:account_id].eq(arel_table[:account_id])).select(1).arel.exists) }
|
||||
scope :localized, ->(locale) { unsupressed.joins(:account_summary).merge(AccountSummary.localized(locale)) }
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue