diff --git a/app/services/blocks_migration.rb b/app/services/blocks_migration.rb index 8b65d79fff31bf68efb07649310ffe3cf72fb603..61c440de4f25da9959a23b42a72c29d6d5bc5ff4 100644 --- a/app/services/blocks_migration.rb +++ b/app/services/blocks_migration.rb @@ -5,22 +5,26 @@ class BlocksMigration def self.cleanup Communication::Website::Post.find_each do |post| - next if post.text.blank? - cleanup_post post + cleanup_item post + end + Communication::Website::Page.find_each do |page| + cleanup_item page end end private - def self.cleanup_post(post) - puts "#{post} (#{post.id}, #{post.university})" - return if post.blocks.any? + def self.cleanup_item(item) + return if item.text.blank? + puts "#{item} (#{item.id}, #{item.university}, #{item.website})" + return if item.blocks.any? puts " migrating" - puts post.text.to_html - # block = post.blocks.create university: post.university, template_kind: :chapter - # data = block.data - # data['text'] = post.text.to_html - # block.data = data - # block.save + puts item.text.to_html + return + block = item.blocks.create university: item.university, template_kind: :chapter + data = block.data + data['text'] = item.text.to_html + block.data = data + block.save end end