BURs: fix tags field not finding all BURs with that tag.

Fix the Tags field in the BUR search form not finding all BURs
mentioning that tag. Specifically, tags that were part of a mass update,
and that were prefixed with `~` or `-` (OR tags and NOT tags), weren't
indexed as tags affected by the BUR.

This requires re-running script/fixes/064_initialize_bulk_update_request_tags.rb
to fix old BURs.
This commit is contained in:
evazion
2022-03-29 21:06:24 -05:00
parent 823fa5c6e9
commit 226faae8ec
3 changed files with 12 additions and 10 deletions

View File

@@ -1,11 +1,14 @@
#!/usr/bin/env ruby
require_relative "../../config/environment"
require_relative "base"
BulkUpdateRequest.transaction do
with_confirmation do
BulkUpdateRequest.find_each do |request|
request.tags = request.processor.affected_tags
request.save!(validate: false)
puts "bur id=#{request.id} tags=#{request.tags}"
if request.changed?
request.save!(validate: false)
puts "bur id=#{request.id} added_tags=#{request.tags - request.tags_before_last_save} removed_tags=#{request.tags_before_last_save - request.tags}"
end
end
end