0
0
Fork 0

Consolidate account scopes for LOWER (index using) username/domain queries (#30451)

This commit is contained in:
Matt Jankowski 2024-05-28 10:11:31 -04:00 committed by GitHub
parent 32c30bf0fd
commit 4a77e477ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 14 additions and 48 deletions

View file

@ -3,7 +3,7 @@
class AccountSuggestions::SettingSource < AccountSuggestions::Source
def get(account, limit: DEFAULT_LIMIT)
if setting_enabled?
base_account_scope(account).where(setting_to_where_condition).limit(limit).pluck(:id).zip([key].cycle)
base_account_scope(account).merge(setting_to_where_condition).limit(limit).pluck(:id).zip([key].cycle)
else
[]
end
@ -25,11 +25,9 @@ class AccountSuggestions::SettingSource < AccountSuggestions::Source
def setting_to_where_condition
usernames_and_domains.map do |(username, domain)|
Arel::Nodes::Grouping.new(
Account.arel_table[:username].lower.eq(username.downcase).and(
Account.arel_table[:domain].lower.eq(domain&.downcase)
)
)
Account
.with_username(username)
.with_domain(domain)
end.reduce(:or)
end