Use private method to choose advanced sql template

This commit is contained in:
Matt Jankowski 2024-09-17 15:22:23 -04:00
parent 8d1bf75cff
commit a72d8a6132

View File

@ -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