mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: improve imported code blocks from bbPress importer
This commit is contained in:
parent
ce09adb5ff
commit
3c4cee5f62
1 changed files with 8 additions and 0 deletions
|
@ -36,10 +36,15 @@ class ImportScripts::Bbpress < ImportScripts::Base
|
||||||
user_registered created_at
|
user_registered created_at
|
||||||
FROM #{table_name 'users'}", cache_rows: false)
|
FROM #{table_name 'users'}", cache_rows: false)
|
||||||
|
|
||||||
|
puts '', "creating users"
|
||||||
|
|
||||||
create_users(users_results) do |u|
|
create_users(users_results) do |u|
|
||||||
ActiveSupport::HashWithIndifferentAccess.new(u)
|
ActiveSupport::HashWithIndifferentAccess.new(u)
|
||||||
end
|
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|
|
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']}
|
result = {id: c['id'], name: c['post_name']}
|
||||||
parent_id = c['post_parent'].to_i
|
parent_id = c['post_parent'].to_i
|
||||||
|
@ -88,6 +93,9 @@ class ImportScripts::Bbpress < ImportScripts::Base
|
||||||
mapped[:id] = post["id"]
|
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[: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"]
|
mapped[:raw] = post["post_content"]
|
||||||
|
if mapped[:raw]
|
||||||
|
mapped[:raw] = mapped[:raw].gsub("<pre><code>", "```\n").gsub("</code></pre>", "\n```")
|
||||||
|
end
|
||||||
mapped[:created_at] = post["post_date"]
|
mapped[:created_at] = post["post_date"]
|
||||||
mapped[:custom_fields] = {import_id: post["id"]}
|
mapped[:custom_fields] = {import_id: post["id"]}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue