about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-02-22 11:53:13 +0100
committerGitHub <noreply@github.com>2023-02-22 11:53:13 +0100
commitf682478de8b5a6e0b524bfca88f3469fd098d64c (patch)
treeed933dd901f09a95299c4773ea3beab2325ff366
parent3ed1b9ebb60a50ea1cb6a229ab25d4e7d6b848c8 (diff)
Fix inefficiency when searching accounts per username in admin interface (#23801)
-rw-r--r--app/models/account.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index 09c450f2a..1ff083e54 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -108,7 +108,7 @@ class Account < ApplicationRecord
   scope :bots, -> { where(actor_type: %w(Application Service)) }
   scope :groups, -> { where(actor_type: 'Group') }
   scope :alphabetic, -> { order(domain: :asc, username: :asc) }
-  scope :matches_username, ->(value) { where(arel_table[:username].matches("#{value}%")) }
+  scope :matches_username, ->(value) { where('lower((username)::text) LIKE lower(?)', "#{value}%") }
   scope :matches_display_name, ->(value) { where(arel_table[:display_name].matches("#{value}%")) }
   scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
   scope :without_unapproved, -> { left_outer_joins(:user).remote.or(left_outer_joins(:user).merge(User.approved.confirmed)) }