Add supported operator and properties for search

This commit is contained in:
noellabo 2023-09-21 17:53:51 +09:00
parent 828eebad48
commit 04ad5e67d0

View file

@ -12,6 +12,23 @@ class SearchQueryTransformer < Parslet::Transform
in in
).freeze ).freeze
SUPPORTED_OPERATOR = %w(
+
-
).freeze
SUPPORTED_PROPERTIES = %w(
image
video
audio
media
poll
link
embed
sensitive
reply
).freeze
class Query class Query
def initialize(clauses, options = {}) def initialize(clauses, options = {})
raise ArgumentError if options[:current_account].nil? raise ArgumentError if options[:current_account].nil?
@ -152,6 +169,8 @@ class SearchQueryTransformer < Parslet::Transform
case prefix case prefix
when 'has', 'is' when 'has', 'is'
raise "Unknown properties: #{term}" unless SUPPORTED_PROPERTIES.include?(term)
@filter = :properties @filter = :properties
@type = :term @type = :term
@term = term @term = term