search: clean up safe_mode / hide_deleted_posts settings.

Change PostQueryBuilder to add rating:s and -status:deleted to the
search inside the constructor instead of inside `#build` and
`#fast_count`. This lets up clean up `#fast_count` so it doesn't have to
reparse the query after adding these tags. This caused aliases to be
evaluated more than once on the post index page.
This commit is contained in:
evazion
2020-05-07 17:05:44 -05:00
parent 67aab0236d
commit d3e4ac7c17
5 changed files with 32 additions and 35 deletions

View File

@@ -134,13 +134,13 @@ class SavedSearch < ApplicationRecord
def queries_for(user_id, label: nil, options: {})
searches = SavedSearch.where(user_id: user_id)
searches = searches.labeled(label) if label.present?
queries = searches.pluck(:query).map { |query| PostQueryBuilder.new(query).to_s }
queries = searches.map(&:normalized_query)
queries.sort.uniq
end
end
def normalized_query
PostQueryBuilder.new(query, normalize_aliases: false).to_s
PostQueryBuilder.new(query).to_s
end
def normalize_query