post queries: parse order:*_count synonyms.
This commit is contained in:
@@ -165,6 +165,14 @@ class PostQuery
|
|||||||
name = @scanner.matched.delete_suffix(":").downcase
|
name = @scanner.matched.delete_suffix(":").downcase
|
||||||
name = name.singularize + "_count" if name.in?(PostQueryBuilder::COUNT_METATAG_SYNONYMS)
|
name = name.singularize + "_count" if name.in?(PostQueryBuilder::COUNT_METATAG_SYNONYMS)
|
||||||
quoted, value = quoted_string
|
quoted, value = quoted_string
|
||||||
|
|
||||||
|
if name == "order"
|
||||||
|
attribute, direction, _tail = value.to_s.downcase.partition(/_(asc|desc)\z/i)
|
||||||
|
if attribute.in?(PostQueryBuilder::COUNT_METATAG_SYNONYMS)
|
||||||
|
value = attribute.singularize + "_count" + direction
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
node(:metatag, name, value, quoted)
|
node(:metatag, name, value, quoted)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -98,6 +98,15 @@ class PostQueryParserTest < ActiveSupport::TestCase
|
|||||||
assert_parse_equals("appeal_count:0", "appeals:0")
|
assert_parse_equals("appeal_count:0", "appeals:0")
|
||||||
assert_parse_equals("approval_count:0", "approvals:0")
|
assert_parse_equals("approval_count:0", "approvals:0")
|
||||||
assert_parse_equals("replacement_count:0", "replacements:0")
|
assert_parse_equals("replacement_count:0", "replacements:0")
|
||||||
|
|
||||||
|
assert_parse_equals("order:comment_count", "order:comments")
|
||||||
|
assert_parse_equals("order:note_count", "order:notes")
|
||||||
|
assert_parse_equals("order:flag_count", "order:flags")
|
||||||
|
assert_parse_equals("order:child_count", "order:children")
|
||||||
|
assert_parse_equals("order:pool_count", "order:pools")
|
||||||
|
assert_parse_equals("order:appeal_count", "order:appeals")
|
||||||
|
assert_parse_equals("order:approval_count", "order:approvals")
|
||||||
|
assert_parse_equals("order:replacement_count", "order:replacements")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "parse wildcard tags correctly" do
|
should "parse wildcard tags correctly" do
|
||||||
|
|||||||
Reference in New Issue
Block a user