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