BURs: change mass updates to not remove left-hand side tags.
Change mass updates to not automatically remove the left-hand side tags from the post. This won't work with full boolean searches in the future and already doesn't work with complex searches involving metatags or OR-tags.
This commit is contained in:
@@ -264,14 +264,11 @@ class BulkUpdateRequestProcessor
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.mass_update(antecedent, consequent, user: User.system)
|
def self.mass_update(antecedent, consequent, user: User.system)
|
||||||
normalized_antecedent = PostQueryBuilder.new(antecedent).split_query
|
|
||||||
normalized_consequent = PostQueryBuilder.new(consequent).parse_tag_edit
|
|
||||||
|
|
||||||
CurrentUser.scoped(user) do
|
CurrentUser.scoped(user) do
|
||||||
Post.anon_tag_match(normalized_antecedent.join(" ")).reorder(nil).parallel_each do |post|
|
Post.anon_tag_match(antecedent).reorder(nil).parallel_each do |post|
|
||||||
post.with_lock do
|
post.with_lock do
|
||||||
tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ")
|
post.tag_string += " " + consequent
|
||||||
post.update(tag_string: tags)
|
post.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "update the tags" do
|
should "update the tags" do
|
||||||
assert_equal("bar baz", @post.reload.tag_string)
|
assert_equal("bar baz foo", @post.reload.tag_string)
|
||||||
assert_equal("approved", @bur.reload.status)
|
assert_equal("approved", @bur.reload.status)
|
||||||
assert_equal(User.system, @post.versions.last.updater)
|
assert_equal(User.system, @post.versions.last.updater)
|
||||||
end
|
end
|
||||||
@@ -575,7 +575,7 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "process mass updates" do
|
should "process mass updates" do
|
||||||
assert_equal("bar baz bbb blah", @post.reload.tag_string)
|
assert_equal("aaa bar baz bbb blah", @post.reload.tag_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "set the alias/implication approvers" do
|
should "set the alias/implication approvers" do
|
||||||
|
|||||||
Reference in New Issue
Block a user