From 05df3a194c3bad7a446cff0f7b61709a6952782b Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 5 Jun 2022 13:55:44 -0500 Subject: [PATCH] posts: add more free metatags. The following metatags no longer count against the tag search limit: * is * id * date * age * filesize * filetype * parent * child * md5 * width * height * duration * mpixels * ratio * score * upvotes * downvotes * favcount * embedded * tagcount * pixiv_id * pixiv These are mostly metatags that have to do with properties of the post itself. Other metatags still count because they involve things like subqueries or joins, or they're more tag-like in function. --- app/logical/post_query.rb | 6 +++++- test/unit/post_query_builder_test.rb | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/logical/post_query.rb b/app/logical/post_query.rb index 633c73a23..aea015e10 100644 --- a/app/logical/post_query.rb +++ b/app/logical/post_query.rb @@ -7,7 +7,11 @@ class PostQuery class TagLimitError < Error; end # Metatags that don't count against the user's tag limit. - UNLIMITED_METATAGS = %w[status rating limit] + UNLIMITED_METATAGS = %w[ + status rating limit is id date age filesize filetype parent child md5 width + height duration mpixels ratio score upvote downvotes favcount embedded + tagcount pixiv_id pixiv + ] # Metatags that define the order of search results. These metatags can't be used more than once per query. ORDER_METATAGS = %w[order ordfav ordfavgroup ordpool] diff --git a/test/unit/post_query_builder_test.rb b/test/unit/post_query_builder_test.rb index bdbede2f9..fa1b79c0a 100644 --- a/test/unit/post_query_builder_test.rb +++ b/test/unit/post_query_builder_test.rb @@ -1353,7 +1353,7 @@ class PostQueryBuilderTest < ActiveSupport::TestCase post1 = create(:post, rating: "s") assert_raise(PostQuery::TagLimitError) do - PostQuery.search("a b c rating:s width:10 height:10 user:bob", tag_limit: 5) + PostQuery.search("a b c user:bob fav:bob pool:disgustingly_adorable", tag_limit: 5) end end @@ -1363,6 +1363,7 @@ class PostQueryBuilderTest < ActiveSupport::TestCase assert_tag_match([post1], "aaa bbb rating:s") assert_tag_match([post1], "aaa bbb status:active") assert_tag_match([post1], "aaa bbb limit:20") + assert_tag_match([post1], "aaa bbb filesize:<100mb width:<10000 height:<10000 limit:20") end should "succeed for exclusive tag searches with no other tag" do