saved searches: fix to use new PostQuery class.

This commit is contained in:
evazion
2022-04-09 23:28:40 -05:00
parent ca5dd61728
commit 219a0959a5
2 changed files with 7 additions and 2 deletions

View File

@@ -174,6 +174,11 @@ class PostQuery
build(AST.new(:and, [ast, *implicit_metatags]))
end
# Return a new PostQuery with terms sorted into alphabetical order.
def sort
build(ast.sort)
end
# Return a new PostQuery converted to conjunctive normal form.
def to_cnf
build(ast.to_cnf)

View File

@@ -146,7 +146,7 @@ class SavedSearch < ApplicationRecord
concerning :Queries do
class_methods do
def normalize_query(query)
PostQueryBuilder.new(query.to_s).normalized_query(sort: false).to_s
PostQuery.new(query.to_s).replace_aliases.to_infix
end
def queries_for(user_id, label: nil)
@@ -166,7 +166,7 @@ class SavedSearch < ApplicationRecord
end
def normalized_query
@normalized_query ||= PostQueryBuilder.new(query).normalized_query.to_s
@normalized_query ||= PostQuery.normalize(query).sort.to_s
end
def rewrite_query(old_name, new_name)