#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
|
||||
|
||||
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
|
||||
|
||||
mysql_user = ENV['MYSQL_USER']
|
||||
@@ -57,12 +59,14 @@ namespace :nico do
|
||||
end
|
||||
post.save!
|
||||
post.resized_thumbnail!
|
||||
sync_post_tags!(post, [Tag.tagme.id])
|
||||
end
|
||||
|
||||
kept_tags = post.tags.reload
|
||||
kept_non_nico_ids = kept_tags.where.not(category: 'nico').pluck(:id).to_set
|
||||
|
||||
desired_nico_ids = []
|
||||
desired_non_nico_ids = []
|
||||
datum['tags'].each do |raw|
|
||||
name = "nico:#{ raw }"
|
||||
tag = Tag.find_or_initialize_by(name:) do |t|
|
||||
@@ -70,17 +74,19 @@ namespace :nico do
|
||||
end
|
||||
tag.save! if tag.new_record?
|
||||
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
|
||||
desired_nico_ids.uniq!
|
||||
|
||||
desired_extra_ids = []
|
||||
desired_extra_ids << Tag.tagme.id if kept_tags.size < 10
|
||||
desired_extra_ids << Tag.bot.id
|
||||
desired_extra_ids.compact!
|
||||
desired_extra_ids.uniq!
|
||||
|
||||
desired_all_ids = kept_non_nico_ids.to_a + desired_nico_ids + desired_extra_ids
|
||||
desired_all_ids = kept_non_nico_ids.to_a + desired_nico_ids
|
||||
desired_non_nico_ids.concat(kept_non_nico_ids.to_a)
|
||||
desired_non_nico_ids.uniq!
|
||||
if kept_non_nico_ids.to_set != desired_non_nico_ids.to_set
|
||||
desired_all_ids << Tag.bot.id
|
||||
end
|
||||
desired_all_ids.uniq!
|
||||
|
||||
sync_post_tags!(post, desired_all_ids)
|
||||
|
||||
Reference in New Issue
Block a user