Fix #1590: id metatag: "id:A..B,C..D,E"
Support searches like the following: * score:<0,>100 (equivalent to `score:<0 or score:>100`) * score:5,10..15,>20 (equivalent to `score:5 or score:10..15 or score:>20`) * id:5,10..15,20..25,30 (equivalent to `id:5 or id:10..15 or id:20..25 or id:30`) This also works inside the `search[id]` URL parameter, and inside other numeric URL search parameters.
This commit is contained in:
@@ -212,6 +212,19 @@ class PostQueryBuilderTest < ActiveSupport::TestCase
|
||||
assert_tag_match([posts[1], posts[0]], "id:#{posts[1].id}..#{posts[0].id}")
|
||||
assert_tag_match([posts[1], posts[0]], "id:#{posts[0].id}...#{posts[2].id}")
|
||||
|
||||
assert_tag_match(posts.reverse, "id:#{posts[0].id},#{posts[1].id}..#{posts[2].id}")
|
||||
assert_tag_match(posts.reverse, "id:#{posts[0].id}..#{posts[1].id},#{posts[2].id}")
|
||||
assert_tag_match(posts.reverse, "id:#{posts[0].id},>=#{posts[1].id}")
|
||||
assert_tag_match(posts.reverse, "id:<=#{posts[1].id},#{posts[2].id}")
|
||||
|
||||
assert_tag_match([], "id:<#{posts[0].id},>#{posts[2].id}")
|
||||
assert_tag_match([posts[2], posts[0]], "id:<=#{posts[0].id},>=#{posts[2].id}")
|
||||
assert_tag_match([posts[2], posts[0]], "id:..#{posts[0].id},#{posts[2].id}..")
|
||||
|
||||
assert_tag_match([posts[1]], "id:<#{posts[0].id},#{posts[1].id},>#{posts[2].id}")
|
||||
assert_tag_match([posts[1]], "id:#{posts[1].id},<#{posts[0].id},>#{posts[2].id}")
|
||||
assert_tag_match([posts[1]], "id:<#{posts[0].id},>#{posts[2].id},#{posts[1].id}")
|
||||
|
||||
assert_tag_match([posts[1], posts[0]], "-id:>#{posts[1].id}")
|
||||
assert_tag_match([posts[2], posts[1]], "-id:<#{posts[1].id}")
|
||||
assert_tag_match([posts[0]], "-id:>=#{posts[1].id}")
|
||||
@@ -219,6 +232,19 @@ class PostQueryBuilderTest < ActiveSupport::TestCase
|
||||
assert_tag_match([posts[0]], "-id:#{posts[1].id}..#{posts[2].id}")
|
||||
assert_tag_match([posts[0]], "-id:#{posts[1].id},#{posts[2].id}")
|
||||
|
||||
assert_tag_match([], "-id:#{posts[0].id},#{posts[1].id}..#{posts[2].id}")
|
||||
assert_tag_match([], "-id:#{posts[0].id}..#{posts[1].id},#{posts[2].id}")
|
||||
assert_tag_match([], "-id:#{posts[0].id},>=#{posts[1].id}")
|
||||
assert_tag_match([], "-id:<=#{posts[1].id},#{posts[2].id}")
|
||||
|
||||
assert_tag_match(posts.reverse, "-id:<#{posts[0].id},>#{posts[2].id}")
|
||||
assert_tag_match([posts[1]], "-id:<=#{posts[0].id},>=#{posts[2].id}")
|
||||
assert_tag_match([posts[1]], "-id:..#{posts[0].id},#{posts[2].id}..")
|
||||
|
||||
assert_tag_match([posts[2], posts[0]], "-id:<#{posts[0].id},#{posts[1].id},>#{posts[2].id}")
|
||||
assert_tag_match([posts[2], posts[0]], "-id:#{posts[1].id},<#{posts[0].id},>#{posts[2].id}")
|
||||
assert_tag_match([posts[2], posts[0]], "-id:<#{posts[0].id},>#{posts[2].id},#{posts[1].id}")
|
||||
|
||||
assert_tag_match([], "id:#{posts[0].id} id:#{posts[2].id}")
|
||||
assert_tag_match([posts[0]], "-id:#{posts[1].id} -id:#{posts[2].id}")
|
||||
assert_tag_match([posts[1]], "id:>#{posts[0].id} id:<#{posts[2].id}")
|
||||
@@ -1048,6 +1074,9 @@ class PostQueryBuilderTest < ActiveSupport::TestCase
|
||||
|
||||
assert_tag_match([post1], "pixiv:none")
|
||||
assert_tag_match([post2], "pixiv:any")
|
||||
|
||||
assert_tag_match([], "-pixiv_id:>40,<50")
|
||||
assert_tag_match([post2], "-pixiv_id:<40,>50")
|
||||
end
|
||||
|
||||
should "return posts for the search: metatag" do
|
||||
|
||||
Reference in New Issue
Block a user