This commit is contained in:
2026-04-19 17:47:22 +09:00
parent f3a2b08359
commit 96307af509
12 changed files with 63 additions and 47 deletions
+7
View File
@@ -0,0 +1,7 @@
class NicoTagVersion < ApplicationRecord
include VersionRecord
belongs_to :tag
validates :name, presence: true
end
+2 -3
View File
@@ -157,7 +157,6 @@ class Tag < ApplicationRecord
target_tag => Tag
affected_post_ids = Set.new
affected_tag_ids = Set.new
Tag.transaction do
Array(source_tags).compact.uniq.each do |source_tag|
@@ -181,7 +180,7 @@ class Tag < ApplicationRecord
end
source_tag.discard!
record_tag_discard!(source_tag, current_by_user: nil)
TagVersioning.record!(source_tag, event_type: :discard, created_by_user:)
if source_tag.nico?
source_tag_name.discard!
@@ -190,7 +189,7 @@ class Tag < ApplicationRecord
updated_at: Time.current)
end
record_tag_version!(target_tag, event_type: :update, created_by_user: nil)
TagVersioning.record!(target_tag, event_type: :update, created_by_user:)
end
Post.where(id: affected_post_ids.to_a).find_each do |post|
-2
View File
@@ -1,8 +1,6 @@
class TagName < ApplicationRecord
include MyDiscard
default_scope -> { kept }
has_one :tag
has_one :wiki_page
+1 -2
View File
@@ -8,8 +8,7 @@ class TagVersion < ApplicationRecord
character: 'character',
general: 'general',
material: 'material',
meta: 'meta',
nico: 'nico' }, validate: true
meta: 'meta' }, validate: true
validates :name, presence: true
validates :category, presence: true