このコミットが含まれているのは:
2026-07-15 08:03:25 +09:00
コミット 58828597d7
7個のファイルの変更156行の追加33行の削除
+21 -1
ファイルの表示
@@ -27,13 +27,24 @@ class PostImportRunner
return { source_row: row['source_row'],
status: 'failed',
errors: preview[:validation_errors] } if preview[:validation_errors].present?
return row.slice('source_row').merge(status: 'skipped') if preview[:skip_reason] == 'existing'
if preview[:skip_reason] == 'existing'
return { source_row: row['source_row'],
status: 'skipped',
existing_post_id: preview[:existing_post_id] }
end
attributes['tags'] = preview[:attributes]['tags']
attributes['url'] = row['url']
post = PostCreator.new(actor: @actor, attributes:).create!
{ source_row: row['source_row'], status: 'created', post: PostRepr.base(post) }
rescue ActiveRecord::RecordInvalid => e
existing_post = existing_post_for_race(row, e.record)
if existing_post
return { source_row: row['source_row'],
status: 'skipped',
existing_post_id: existing_post.id }
end
{ source_row: row['source_row'], status: 'failed', errors: e.record.errors.to_hash }
rescue Tag::NicoTagNormalisationError
{ source_row: row['source_row'],
@@ -54,4 +65,13 @@ class PostImportRunner
status: 'failed',
errors: { base: ['登録中にエラーが発生しました.'] } }
end
def existing_post_for_race row, record
return nil unless record.errors.of_kind?(:url, :taken)
normal_url = PostUrlNormaliser.normalise(row['url'])
return nil if normal_url.blank?
Post.find_by(url: normal_url)
end
end