Merge branch 'main' into feature/206
This commit is contained in:
@@ -47,7 +47,6 @@ namespace :nico do
|
|||||||
data = JSON.parse(stdout)
|
data = JSON.parse(stdout)
|
||||||
data.each do |datum|
|
data.each do |datum|
|
||||||
code = datum['code']
|
code = datum['code']
|
||||||
|
|
||||||
post =
|
post =
|
||||||
Post
|
Post
|
||||||
.where('url REGEXP ?', "nicovideo\\.jp/watch/#{ Regexp.escape(code) }([^0-9]|$)")
|
.where('url REGEXP ?', "nicovideo\\.jp/watch/#{ Regexp.escape(code) }([^0-9]|$)")
|
||||||
@@ -94,14 +93,15 @@ namespace :nico do
|
|||||||
sync_post_tags!(post, [Tag.tagme.id, Tag.bot.id, Tag.niconico.id, Tag.video.id])
|
sync_post_tags!(post, [Tag.tagme.id, Tag.bot.id, Tag.niconico.id, Tag.video.id])
|
||||||
end
|
end
|
||||||
|
|
||||||
kept_ids = PostTag.kept.where(post_id: post.id).pluck(:tag_id).to_set
|
kept_ids = post.tags.pluck(:id).to_set
|
||||||
kept_non_nico_ids = post.tags.where.not(category: 'nico').pluck(:id).to_set
|
kept_non_nico_ids = post.tags.not_nico.pluck(:id).to_set
|
||||||
|
|
||||||
desired_nico_ids = []
|
desired_nico_ids = []
|
||||||
desired_non_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_create_by_tag_name!(name, category: 'nico')
|
tag = Tag.find_or_create_by_tag_name!(name, category: :nico)
|
||||||
desired_nico_ids << tag.id
|
desired_nico_ids << tag.id
|
||||||
unless tag.id.in?(kept_ids)
|
unless tag.id.in?(kept_ids)
|
||||||
linked_ids = tag.linked_tags.pluck(:id)
|
linked_ids = tag.linked_tags.pluck(:id)
|
||||||
@@ -109,6 +109,13 @@ namespace :nico do
|
|||||||
desired_nico_ids.concat(linked_ids)
|
desired_nico_ids.concat(linked_ids)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
deerjikist = Deerjikist.find_by(platform: :nico, code: datum['user'])
|
||||||
|
if deerjikist
|
||||||
|
desired_non_nico_ids << deerjikist.tag_id
|
||||||
|
desired_nico_ids << deerjikist.tag_id
|
||||||
|
end
|
||||||
|
|
||||||
desired_nico_ids.uniq!
|
desired_nico_ids.uniq!
|
||||||
|
|
||||||
desired_all_ids = kept_non_nico_ids.to_a + desired_nico_ids
|
desired_all_ids = kept_non_nico_ids.to_a + desired_nico_ids
|
||||||
|
|||||||
Reference in New Issue
Block a user