[BURs] Don't use tag_string_diff for tag nuking

This doesn't have the same issue as mass updates, but
it doesn't hurt to change this away from tag_string_diff as well

Aliases/Implications still do this but considering this has been the case
for 4 years now I don't believe this to be a problem
This commit is contained in:
Earlopain 2024-02-26 16:56:20 +01:00
parent ca56ef3529
commit a816ee3b34
No known key found for this signature in database
GPG Key ID: 48860312319ADF61
2 changed files with 11 additions and 2 deletions

View File

@ -28,7 +28,7 @@ class TagNukeJob < ApplicationJob
Post.sql_raw_tag_match(tag_name).find_each do |post|
post.with_lock do
post.do_not_version_changes = true
post.tag_string_diff = "-#{tag_name}"
post.remove_tag(tag_name)
post.save
end
end
@ -50,7 +50,7 @@ class TagNukeJob < ApplicationJob
TagRelUndo.where(tag_rel: tag, applied: false).find_each do |tag_rel_undo|
Post.where(id: tag_rel_undo.undo_data).find_each do |post|
post.do_not_version_changes = true
post.tag_string_diff = tag.name
post.add_tag(tag.name)
post.save
end
tag_rel_undo.update(applied: true)

View File

@ -12,4 +12,13 @@ class TagNukeJobTest < ActiveJob::TestCase
assert_equal("aa b c", p1.tag_string)
assert_equal("dd y z", p2.tag_string)
end
should "ignore aliases" do
CurrentUser.user = create(:user)
post = create(:post, tag_string: "extra new_tag")
create(:tag_alias, antecedent_name: "old_tag", consequent_name: "new_tag", status: "active")
TagNukeJob.perform_now("old_tag", CurrentUser.user.id)
assert_equal("extra new_tag", post.reload.tag_string)
end
end