|
|
|
@@ -336,8 +336,27 @@ class TagsController < ApplicationController |
|
|
|
end |
|
|
|
|
|
|
|
def update_aliases! tag, alias_names |
|
|
|
alias_names = alias_names.uniq |
|
|
|
|
|
|
|
affected_tags = [tag] |
|
|
|
|
|
|
|
current_aliases = tag.tag_name.aliases.to_a |
|
|
|
|
|
|
|
current_aliases.each do |alias_tag_name| |
|
|
|
next if alias_names.include?(alias_tag_name.name) |
|
|
|
|
|
|
|
affected_tags << alias_tag_name.canonical&.tag |
|
|
|
end |
|
|
|
|
|
|
|
alias_names.each do |alias_name| |
|
|
|
alias_tag_name = TagName.find_undiscard_or_create_by!(name: alias_name) |
|
|
|
affected_tags << alias_tag_name.canonical&.tag |
|
|
|
end |
|
|
|
|
|
|
|
affected_tags.compact.uniq.each do |affected_tag| |
|
|
|
TagVersioning.ensure_snapshot!(affected_tag, created_by_user: current_user) |
|
|
|
end |
|
|
|
|
|
|
|
current_aliases.each do |alias_tag_name| |
|
|
|
next if alias_names.include?(alias_tag_name.name) |
|
|
|
|
|
|
|
@@ -348,6 +367,10 @@ class TagsController < ApplicationController |
|
|
|
alias_tag_name = TagName.find_undiscard_or_create_by!(name: alias_name) |
|
|
|
alias_tag_name.update!(canonical: tag.tag_name) |
|
|
|
end |
|
|
|
|
|
|
|
affected_tags.compact.uniq.each do |affected_tag| |
|
|
|
record_tag_version!(affected_tag, event_type: :update, created_by_user: current_user) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
def update_parent_tags! tag, parent_names |
|
|
|
|