#55 いったん中断;外部タグ分離優先

このコミットが含まれているのは:
2026-09-22 02:56:58 +09:00
コミット 1b1130ccd9
10個のファイルの変更98行の追加42行の削除
+9 -9
ファイルの表示
@@ -9,7 +9,7 @@ class PostCreator
@field_warnings = { }
end
def create!
def create!(locale)
thumbnail_attachment = prepare_thumbnail_attachment
post = Post.new(title: @attributes[:title].presence,
url: @attributes[:url],
@@ -25,7 +25,7 @@ class PostCreator
post_tags = planned_post_tags
sections = planned_sections
TagVersioning.record_tag_snapshots!(snapshot_tags, created_by_user: @actor)
post.video_ms = planned_video_ms
post.video_ms = planned_video_ms(locale)
post.save!
sync_post_tags!(post, post_tags, sections)
sync_parent_posts!(post, planned_parent_post_ids)
@@ -53,15 +53,15 @@ class PostCreator
def planned_parent_post_ids = planned_create_attributes[:normalised_parent_post_ids]
def planned_video_ms
planned_create_attributes[:video_ms]
def planned_video_ms locale
planned_create_attributes(locale)[:video_ms]
end
def planned_create_attributes
def planned_create_attributes locale
@planned_create_attributes ||= begin
if @attributes.key?(:snapshot_tag_specs)
snapshot_tags = materialise_tags(@attributes[:snapshot_tag_specs] || [])
post_tags = materialise_tags(@attributes[:post_tag_specs] || [])
snapshot_tags = materialise_tags(locale, @attributes[:snapshot_tag_specs] || [])
post_tags = materialise_tags(locale, @attributes[:post_tag_specs] || [])
{
snapshot_tags: snapshot_tags,
post_tags: post_tags,
@@ -92,13 +92,13 @@ class PostCreator
video_ms: plan[:video_ms] }
end
def materialise_tags specs
def materialise_tags locale, specs
Array(specs).each_with_object({ }) do |spec, tags|
name = spec[:name] || spec['name']
category = spec[:category] || spec['category']
next if name.blank? || category.blank?
tag = Tag.find_or_create_by_tag_name!(name, category:)
tag = Tag.find_or_create_by_tag_name!(locale, name, category:)
tag.update!(category:) if tag.category.to_sym != category.to_sym
tags[name] ||= tag
end.values