From 3c4cee5f629c73a921506812aeb454612eeeb89b Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 20 Mar 2015 15:54:42 -0400 Subject: [PATCH] FIX: improve imported code blocks from bbPress importer --- script/import_scripts/bbpress.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/script/import_scripts/bbpress.rb b/script/import_scripts/bbpress.rb index 3f28d3668..3ea8778ce 100644 --- a/script/import_scripts/bbpress.rb +++ b/script/import_scripts/bbpress.rb @@ -36,10 +36,15 @@ class ImportScripts::Bbpress < ImportScripts::Base user_registered created_at FROM #{table_name 'users'}", cache_rows: false) + puts '', "creating users" + create_users(users_results) do |u| ActiveSupport::HashWithIndifferentAccess.new(u) end + + puts '', '', "creating categories" + create_categories(@client.query("SELECT id, post_name, post_parent from #{table_name 'posts'} WHERE post_type = 'forum' AND post_name != '' ORDER BY post_parent")) do |c| result = {id: c['id'], name: c['post_name']} parent_id = c['post_parent'].to_i @@ -88,6 +93,9 @@ class ImportScripts::Bbpress < ImportScripts::Base mapped[:id] = post["id"] mapped[:user_id] = user_id_from_imported_user_id(post["post_author"]) || find_user_by_import_id(post["post_author"]).try(:id) || -1 mapped[:raw] = post["post_content"] + if mapped[:raw] + mapped[:raw] = mapped[:raw].gsub("
", "```\n").gsub("
", "\n```") + end mapped[:created_at] = post["post_date"] mapped[:custom_fields] = {import_id: post["id"]}