mirror of
https://github.com/discourse/discourse.git
synced 2025-04-16 20:59:06 +08:00
Add subcategory support to BBPress import
This commit is contained in:
parent
83a2a832b1
commit
50bf066afd
@ -2,12 +2,12 @@
|
|||||||
# `createdb bbpress`
|
# `createdb bbpress`
|
||||||
# `bundle exec rake db:migrate`
|
# `bundle exec rake db:migrate`
|
||||||
|
|
||||||
|
require 'mysql2'
|
||||||
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
|
require File.expand_path(File.dirname(__FILE__) + "/base.rb")
|
||||||
|
|
||||||
BB_PRESS_DB = "bbpress"
|
BB_PRESS_DB = ENV['BBPRESS_DB'] || "bbpress"
|
||||||
DB_TABLE_PREFIX = "wp_"
|
DB_TABLE_PREFIX = "wp_"
|
||||||
|
|
||||||
require 'mysql2'
|
|
||||||
|
|
||||||
class ImportScripts::Bbpress < ImportScripts::Base
|
class ImportScripts::Bbpress < ImportScripts::Base
|
||||||
|
|
||||||
@ -40,8 +40,13 @@ class ImportScripts::Bbpress < ImportScripts::Base
|
|||||||
ActiveSupport::HashWithIndifferentAccess.new(u)
|
ActiveSupport::HashWithIndifferentAccess.new(u)
|
||||||
end
|
end
|
||||||
|
|
||||||
create_categories(@client.query("SELECT id, post_name from #{table_name 'posts'} WHERE post_type = 'forum' AND post_name != ''")) 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|
|
||||||
{id: c['id'], name: c['post_name']}
|
result = {id: c['id'], name: c['post_name']}
|
||||||
|
parent_id = c['post_parent'].to_i
|
||||||
|
if parent_id > 0
|
||||||
|
result[:parent_category_id] = category_id_from_imported_category_id(parent_id)
|
||||||
|
end
|
||||||
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
import_posts
|
import_posts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user