Fix call to inefficient delete_matched cache method in domain blocks (#28367)

This commit is contained in:
Claire 2023-12-19 11:27:37 +01:00 committed by GitHub
parent 90371a4fc4
commit d7875adad2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 104 additions and 57 deletions

View file

@ -60,12 +60,6 @@ module AccountInteractions
end
end
def domain_blocking_map(target_account_ids, account_id)
accounts_map = Account.where(id: target_account_ids).select('id, domain').each_with_object({}) { |a, h| h[a.id] = a.domain }
blocked_domains = domain_blocking_map_by_domain(accounts_map.values.compact, account_id)
accounts_map.reduce({}) { |h, (id, domain)| h.merge(id => blocked_domains[domain]) }
end
def domain_blocking_map_by_domain(target_domains, account_id)
follow_mapping(AccountDomainBlock.where(account_id: account_id, domain: target_domains), :domain)
end