このコミットが含まれているのは:
+12
-14
@@ -148,25 +148,23 @@ class Tag < ApplicationRecord
|
||||
target_tag => Tag
|
||||
|
||||
Tag.transaction do
|
||||
Array(source_tags).compact.uniq.each do |st|
|
||||
st => Tag
|
||||
Array(source_tags).compact.uniq.each do |source_tag|
|
||||
source_tag => Tag
|
||||
|
||||
next if st == target_tag
|
||||
next if source_tag == target_tag
|
||||
|
||||
st.post_tags.find_each do |pt|
|
||||
if PostTag.kept.exists?(post_id: pt.post_id, tag_id: target_tag.id)
|
||||
pt.discard_by!(nil)
|
||||
# discard 後の update! は禁止なので DB を直に更新
|
||||
pt.update_columns(tag_id: target_tag.id, updated_at: Time.current)
|
||||
else
|
||||
pt.update!(tag: target_tag)
|
||||
source_tag.post_tags.kept.find_each do |source_pt|
|
||||
post_id = source_pt.post_id
|
||||
source_pt.discard_by!(nil)
|
||||
unless PostTag.kept.exists?(post_id:, tag: target_tag)
|
||||
PostTag.create!(post_id:, tag: target_tag)
|
||||
end
|
||||
end
|
||||
|
||||
tag_name = st.tag_name
|
||||
st.discard!
|
||||
tag_name.reload
|
||||
tag_name.update!(canonical: target_tag.tag_name)
|
||||
source_tag_name = source_tag.tag_name
|
||||
source_tag.discard!
|
||||
source_tag_name.reload
|
||||
source_tag_name.update!(canonical: target_tag.tag_name)
|
||||
end
|
||||
|
||||
# 投稿件数を再集計
|
||||
|
||||
新しい課題から参照
ユーザをブロックする