From a72d8a6132eb6714e6aecc0b6de7626846b8d2a4 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 17 Sep 2024 15:22:23 -0400 Subject: [PATCH] Use private method to choose advanced sql template --- app/queries/account_search_query.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/queries/account_search_query.rb b/app/queries/account_search_query.rb index bd9105ed1e5..155a6c10fa8 100644 --- a/app/queries/account_search_query.rb +++ b/app/queries/account_search_query.rb @@ -121,9 +121,7 @@ class AccountSearchQuery end def advanced_search(account, following: false) - sql_template = following ? ADVANCED_SEARCH_WITH_FOLLOWING : ADVANCED_SEARCH_WITHOUT_FOLLOWING - - Account.find_by_sql([sql_template, { id: account.id, limit: @limit, offset: @offset, tsquery: generate_query_for_search }]).tap do |records| + Account.find_by_sql([advanced_sql_template(following), { id: account.id, limit: @limit, offset: @offset, tsquery: generate_query_for_search }]).tap do |records| ActiveRecord::Associations::Preloader.new(records: records, associations: [:account_stat, { user: :role }]).call end end @@ -143,4 +141,8 @@ class AccountSearchQuery @terms .gsub(DISALLOWED_TSQUERY_CHARACTERS, ' ') end + + def advanced_sql_template(following) + following ? ADVANCED_SEARCH_WITH_FOLLOWING : ADVANCED_SEARCH_WITHOUT_FOLLOWING + end end