From 4fcae8045702991129c26ecc080e8e12a6d9b52a Mon Sep 17 00:00:00 2001 From: azuregc7 Date: Sat, 20 Feb 2021 13:11:47 +0000 Subject: [PATCH] Feature/username search case --- app/models/account.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/account.rb b/app/models/account.rb index 10dc7ae5..e3e1181c 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -100,9 +100,9 @@ class Account < ApplicationRecord scope :bots, -> { where(actor_type: %w(Application Service)) } scope :alphabetic, -> { order(domain: :asc, username: :asc) } scope :by_domain_accounts, -> { group(:id).select(:domain, 'COUNT(*) AS accounts_count').order('accounts_count desc') } - scope :matches_username, ->(value) { where(arel_table[:username].matches("#{value}%")) } + scope :matches_username, ->(value) { where(arel_table[:username].lower.matches("#{value.downcase}%")) } scope :matches_display_name, ->(value) { where(arel_table[:display_name].matches("#{value}%")) } - scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) } + scope :matches_domain, ->(value) { where(arel_table[:domain].lower.matches("%#{value.downcase}%")) } scope :searchable, -> { without_suspended.where(moved_to_account_id: nil) } scope :discoverable, -> { searchable.without_silenced.where(discoverable: true).joins(:account_stat).where(AccountStat.arel_table[:followers_count].gteq(MIN_FOLLOWERS_DISCOVERY)) } scope :tagged_with, ->(tag) { joins(:accounts_tags).where(accounts_tags: { tag_id: tag }) }