#181 バグ #181 #181 #181 Co-authored-by: miteruzo <miteruzo@naver.com> Reviewed-on: #182
This commit was merged in pull request #182.
This commit is contained in:
@@ -27,7 +27,9 @@ namespace :nico do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
PostTag.where(post_id: post.id, tag_id: to_remove.to_a).kept.find_each(&:discard!)
|
PostTag.where(post_id: post.id, tag_id: to_remove.to_a).kept.find_each do |pt|
|
||||||
|
pt.discard_by!(nil)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mysql_user = ENV['MYSQL_USER']
|
mysql_user = ENV['MYSQL_USER']
|
||||||
@@ -57,12 +59,14 @@ namespace :nico do
|
|||||||
end
|
end
|
||||||
post.save!
|
post.save!
|
||||||
post.resized_thumbnail!
|
post.resized_thumbnail!
|
||||||
|
sync_post_tags!(post, [Tag.tagme.id])
|
||||||
end
|
end
|
||||||
|
|
||||||
kept_tags = post.tags.reload
|
kept_tags = post.tags.reload
|
||||||
kept_non_nico_ids = kept_tags.where.not(category: 'nico').pluck(:id).to_set
|
kept_non_nico_ids = kept_tags.where.not(category: 'nico').pluck(:id).to_set
|
||||||
|
|
||||||
desired_nico_ids = []
|
desired_nico_ids = []
|
||||||
|
desired_non_nico_ids = []
|
||||||
datum['tags'].each do |raw|
|
datum['tags'].each do |raw|
|
||||||
name = "nico:#{ raw }"
|
name = "nico:#{ raw }"
|
||||||
tag = Tag.find_or_initialize_by(name:) do |t|
|
tag = Tag.find_or_initialize_by(name:) do |t|
|
||||||
@@ -70,17 +74,19 @@ namespace :nico do
|
|||||||
end
|
end
|
||||||
tag.save! if tag.new_record?
|
tag.save! if tag.new_record?
|
||||||
desired_nico_ids << tag.id
|
desired_nico_ids << tag.id
|
||||||
desired_nico_ids.concat(tag.linked_tags.pluck(:id))
|
unless tag.in?(kept_tags)
|
||||||
|
desired_non_nico_ids.concat(tag.linked_tags.pluck(:id))
|
||||||
|
desired_nico_ids.concat(tag.linked_tags.pluck(:id))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
desired_nico_ids.uniq!
|
desired_nico_ids.uniq!
|
||||||
|
|
||||||
desired_extra_ids = []
|
desired_all_ids = kept_non_nico_ids.to_a + desired_nico_ids
|
||||||
desired_extra_ids << Tag.tagme.id if kept_tags.size < 10
|
desired_non_nico_ids.concat(kept_non_nico_ids.to_a)
|
||||||
desired_extra_ids << Tag.bot.id
|
desired_non_nico_ids.uniq!
|
||||||
desired_extra_ids.compact!
|
if kept_non_nico_ids.to_set != desired_non_nico_ids.to_set
|
||||||
desired_extra_ids.uniq!
|
desired_all_ids << Tag.bot.id
|
||||||
|
end
|
||||||
desired_all_ids = kept_non_nico_ids.to_a + desired_nico_ids + desired_extra_ids
|
|
||||||
desired_all_ids.uniq!
|
desired_all_ids.uniq!
|
||||||
|
|
||||||
sync_post_tags!(post, desired_all_ids)
|
sync_post_tags!(post, desired_all_ids)
|
||||||
|
|||||||
Reference in New Issue
Block a user