Consolidate account scopes for LOWER
(index using) username/domain queries (#30451)
This commit is contained in:
parent
32c30bf0fd
commit
4a77e477ee
6 changed files with 14 additions and 48 deletions
|
@ -81,7 +81,7 @@ class ReportService < BaseService
|
|||
|
||||
# If the account making reports is remote, it is likely anonymized so we have to relax the requirements for attaching statuses.
|
||||
domain = @source_account.domain.to_s.downcase
|
||||
has_followers = @target_account.followers.where(Account.arel_table[:domain].lower.eq(domain)).exists?
|
||||
has_followers = @target_account.followers.with_domain(domain).exists?
|
||||
visibility = has_followers ? %i(public unlisted private) : %i(public unlisted)
|
||||
scope = @target_account.statuses.with_discarded
|
||||
scope.merge!(scope.where(visibility: visibility).or(scope.where('EXISTS (SELECT 1 FROM mentions m JOIN accounts a ON m.account_id = a.id WHERE lower(a.domain) = ?)', domain)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue