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

@@ -196,18 +196,17 @@ class BulkUpdateRequestProcessor
end
end
# The list of tags in the script. Used for search BURs by tag.
# @return [Tag] the list of tags
# The list of tags in the script. Used to search BURs by tag.
# @return [Array<String>] the list of tags
def affected_tags
commands.flat_map do |command, *args|
case command
when :create_alias, :remove_alias, :create_implication, :remove_implication, :rename
[args[0], args[1]]
when :mass_update
tags = PostQueryBuilder.new(args[0]).tags + PostQueryBuilder.new(args[1]).tags
tags.reject(&:negated).reject(&:optional).reject(&:wildcard).map(&:name)
PostQuery.new(args[0]).tag_names + PostQuery.new(args[1]).tag_names
when :nuke
PostQueryBuilder.new(args[0]).tags.map(&:name)
PostQuery.new(args[0]).tag_names
when :change_category
args[0]
end