search: rename artcomm metatag to commentaryupdater.
* Rename the artcomm:<user> metatag to commentaryupdater:<user>. * Add support for negated -commentaryupdater:<user> searches.
This commit is contained in:
@@ -128,6 +128,7 @@ Autocomplete.initialize_tag_autocomplete = function() {
|
|||||||
case "comm":
|
case "comm":
|
||||||
case "noter":
|
case "noter":
|
||||||
case "noteupdater":
|
case "noteupdater":
|
||||||
|
case "commentaryupdater":
|
||||||
case "artcomm":
|
case "artcomm":
|
||||||
case "fav":
|
case "fav":
|
||||||
case "ordfav":
|
case "ordfav":
|
||||||
|
|||||||
@@ -12,13 +12,46 @@ class PostQueryBuilder
|
|||||||
COUNT_METATAG_SYNONYMS = COUNT_METATAGS.map { |str| str.delete_suffix("_count").pluralize }
|
COUNT_METATAG_SYNONYMS = COUNT_METATAGS.map { |str| str.delete_suffix("_count").pluralize }
|
||||||
|
|
||||||
METATAGS = %w[
|
METATAGS = %w[
|
||||||
-user user -approver approver -commenter commenter comm -noter noter
|
-user user
|
||||||
-noteupdater noteupdater artcomm -pool pool ordpool -favgroup favgroup -fav
|
-approver approver
|
||||||
fav -ordfav ordfav md5 -rating rating -locked locked width height mpixels ratio
|
-commenter commenter comm
|
||||||
score favcount filesize source -source id -id date age order limit -status
|
-noter noter
|
||||||
status tagcount parent -parent child pixiv_id pixiv search -upvote upvote
|
-noteupdater noteupdater
|
||||||
-downvote downvote filetype -filetype flagger -flagger appealer -appealer
|
-artcomm artcomm
|
||||||
disapproved -disapproved embedded
|
-commentaryupdater commentaryupdater
|
||||||
|
-flagger flagger
|
||||||
|
-appealer appealer
|
||||||
|
-upvote upvote
|
||||||
|
-downvote downvote
|
||||||
|
-fav fav
|
||||||
|
-ordfav ordfav
|
||||||
|
-favgroup favgroup
|
||||||
|
-pool pool ordpool
|
||||||
|
-id id
|
||||||
|
-rating rating
|
||||||
|
-locked locked
|
||||||
|
-source source
|
||||||
|
-status status
|
||||||
|
-filetype filetype
|
||||||
|
-disapproved disapproved
|
||||||
|
-parent parent
|
||||||
|
md5
|
||||||
|
width
|
||||||
|
height
|
||||||
|
mpixels
|
||||||
|
ratio
|
||||||
|
score
|
||||||
|
favcount
|
||||||
|
filesize
|
||||||
|
date
|
||||||
|
age
|
||||||
|
order
|
||||||
|
limit
|
||||||
|
tagcount
|
||||||
|
child
|
||||||
|
pixiv_id pixiv
|
||||||
|
search
|
||||||
|
embedded
|
||||||
] + TagCategory.short_name_list.map {|x| "#{x}tags"} + COUNT_METATAGS + COUNT_METATAG_SYNONYMS
|
] + TagCategory.short_name_list.map {|x| "#{x}tags"} + COUNT_METATAGS + COUNT_METATAG_SYNONYMS
|
||||||
|
|
||||||
ORDER_METATAGS = %w[
|
ORDER_METATAGS = %w[
|
||||||
@@ -403,10 +436,12 @@ class PostQueryBuilder
|
|||||||
relation = add_user_subquery_relation(NoteVersion.unscoped, note_updater, relation, field: :updater)
|
relation = add_user_subquery_relation(NoteVersion.unscoped, note_updater, relation, field: :updater)
|
||||||
end
|
end
|
||||||
|
|
||||||
if q[:artcomm_ids]
|
q[:commentary_updater_neg].to_a.each do |username|
|
||||||
q[:artcomm_ids].each do |artcomm_id|
|
relation = add_user_subquery_relation(ArtistCommentaryVersion.unscoped, username, relation, field: :updater).negate
|
||||||
relation = relation.where("posts.id": ArtistCommentaryVersion.unscoped.where(updater_id: artcomm_id).select("post_id").distinct)
|
end
|
||||||
end
|
|
||||||
|
q[:commentary_updater].to_a.each do |username|
|
||||||
|
relation = add_user_subquery_relation(ArtistCommentaryVersion.unscoped, username, relation, field: :updater)
|
||||||
end
|
end
|
||||||
|
|
||||||
if q[:post_id_negated]
|
if q[:post_id_negated]
|
||||||
@@ -785,10 +820,13 @@ class PostQueryBuilder
|
|||||||
q[:note_updater_neg] ||= []
|
q[:note_updater_neg] ||= []
|
||||||
q[:note_updater_neg] << g2
|
q[:note_updater_neg] << g2
|
||||||
|
|
||||||
when "artcomm"
|
when "-commentaryupdater", "-artcomm"
|
||||||
q[:artcomm_ids] ||= []
|
q[:commentary_updater_neg] ||= []
|
||||||
user_id = User.name_to_id(g2)
|
q[:commentary_updater_neg] << g2
|
||||||
q[:artcomm_ids] << user_id unless user_id.blank?
|
|
||||||
|
when "commentaryupdater", "artcomm"
|
||||||
|
q[:commentary_updater] ||= []
|
||||||
|
q[:commentary_updater] << g2
|
||||||
|
|
||||||
when "disapproved"
|
when "disapproved"
|
||||||
q[:disapproved] ||= []
|
q[:disapproved] ||= []
|
||||||
|
|||||||
@@ -2206,15 +2206,26 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
assert_tag_match([posts[1]], "deleted_notes:1")
|
assert_tag_match([posts[1]], "deleted_notes:1")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return posts for the artcomm:<name> metatag" do
|
should "return posts for the commentaryupdater:<name> metatag" do
|
||||||
users = FactoryBot.create_list(:user, 2)
|
user1 = create(:user)
|
||||||
posts = FactoryBot.create_list(:post, 2)
|
user2 = create(:user)
|
||||||
users.zip(posts).map do |u, p|
|
post1 = create(:post)
|
||||||
CurrentUser.scoped(u) { FactoryBot.create(:artist_commentary, post: p) }
|
post2 = create(:post)
|
||||||
end
|
artcomm1 = as(user1) { create(:artist_commentary, post: post1) }
|
||||||
|
artcomm2 = as(user2) { create(:artist_commentary, post: post2) }
|
||||||
|
|
||||||
assert_tag_match([posts[0]], "artcomm:#{users[0].name}")
|
assert_tag_match([post1], "commentaryupdater:#{user1.name}")
|
||||||
assert_tag_match([posts[1]], "artcomm:#{users[1].name}")
|
assert_tag_match([post2], "commentaryupdater:#{user2.name}")
|
||||||
|
assert_tag_match([post2], "-commentaryupdater:#{user1.name}")
|
||||||
|
assert_tag_match([post1], "-commentaryupdater:#{user2.name}")
|
||||||
|
|
||||||
|
assert_tag_match([post1], "artcomm:#{user1.name}")
|
||||||
|
assert_tag_match([post2], "artcomm:#{user2.name}")
|
||||||
|
assert_tag_match([post2], "-artcomm:#{user1.name}")
|
||||||
|
assert_tag_match([post1], "-artcomm:#{user2.name}")
|
||||||
|
|
||||||
|
assert_tag_match([post2, post1], "commentaryupdater:any")
|
||||||
|
assert_tag_match([], "commentaryupdater:none")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return posts for the date:<d> metatag" do
|
should "return posts for the date:<d> metatag" do
|
||||||
|
|||||||
Reference in New Issue
Block a user