mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-02 11:59:17 -05:00
update Jive import script
This commit is contained in:
parent
fc92166d5f
commit
f74f2f0b4f
1 changed files with 10 additions and 11 deletions
|
@ -6,7 +6,7 @@ require File.expand_path(File.dirname(__FILE__) + "/base.rb")
|
||||||
class ImportScripts::Jive < ImportScripts::Base
|
class ImportScripts::Jive < ImportScripts::Base
|
||||||
|
|
||||||
BATCH_SIZE = 1000
|
BATCH_SIZE = 1000
|
||||||
CATEGORY_IDS = [2023,2003,2004,2042,2036,2029] # categories that should be skipped
|
CATEGORY_IDS = [2023,2003,2004,2042,2036,2029] # categories that should be imported
|
||||||
|
|
||||||
def initialize(path)
|
def initialize(path)
|
||||||
@path = path
|
@path = path
|
||||||
|
@ -127,7 +127,7 @@ class ImportScripts::Jive < ImportScripts::Base
|
||||||
puts "", "importing groups..."
|
puts "", "importing groups..."
|
||||||
|
|
||||||
rows = []
|
rows = []
|
||||||
csv_parse("group") do |row|
|
csv_parse("groups") do |row|
|
||||||
rows << {id: row.groupid, name: row.name}
|
rows << {id: row.groupid, name: row.name}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -142,14 +142,13 @@ class ImportScripts::Jive < ImportScripts::Base
|
||||||
count = 0
|
count = 0
|
||||||
users = []
|
users = []
|
||||||
|
|
||||||
total = total_rows("user")
|
total = total_rows("users")
|
||||||
|
|
||||||
csv_parse("user") do |row|
|
csv_parse("users") do |row|
|
||||||
|
|
||||||
id = row.userid
|
id = row.userid
|
||||||
|
|
||||||
# append "-x" at the end of each email
|
email = "#{row.email}"
|
||||||
email = "#{row.email}-x"
|
|
||||||
|
|
||||||
# fake it
|
# fake it
|
||||||
if row.email.blank? || row.email !~ /@/
|
if row.email.blank? || row.email !~ /@/
|
||||||
|
@ -174,7 +173,7 @@ class ImportScripts::Jive < ImportScripts::Base
|
||||||
created_at: created_at,
|
created_at: created_at,
|
||||||
last_seen_at: last_seen_at,
|
last_seen_at: last_seen_at,
|
||||||
active: is_activated.to_i == 1,
|
active: is_activated.to_i == 1,
|
||||||
approved: is_activated.to_i == 1
|
approved: true
|
||||||
}
|
}
|
||||||
|
|
||||||
count += 1
|
count += 1
|
||||||
|
@ -203,7 +202,7 @@ class ImportScripts::Jive < ImportScripts::Base
|
||||||
def import_categories
|
def import_categories
|
||||||
rows = []
|
rows = []
|
||||||
|
|
||||||
csv_parse("community") do |row|
|
csv_parse("communities") do |row|
|
||||||
next unless CATEGORY_IDS.include?(row.communityid.to_i)
|
next unless CATEGORY_IDS.include?(row.communityid.to_i)
|
||||||
rows << {id: row.communityid, name: "#{row.name} (#{row.communityid})"}
|
rows << {id: row.communityid, name: "#{row.name} (#{row.communityid})"}
|
||||||
end
|
end
|
||||||
|
@ -279,7 +278,7 @@ class ImportScripts::Jive < ImportScripts::Base
|
||||||
topic_map = {}
|
topic_map = {}
|
||||||
thread_map = {}
|
thread_map = {}
|
||||||
|
|
||||||
csv_parse("message") do |thread|
|
csv_parse("messages") do |thread|
|
||||||
|
|
||||||
next unless CATEGORY_IDS.include?(thread.containerid.to_i)
|
next unless CATEGORY_IDS.include?(thread.containerid.to_i)
|
||||||
|
|
||||||
|
@ -301,7 +300,7 @@ class ImportScripts::Jive < ImportScripts::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
total = total_rows("message")
|
total = total_rows("messages")
|
||||||
posts = []
|
posts = []
|
||||||
count = 0
|
count = 0
|
||||||
|
|
||||||
|
@ -310,7 +309,7 @@ class ImportScripts::Jive < ImportScripts::Base
|
||||||
count+=1
|
count+=1
|
||||||
end
|
end
|
||||||
|
|
||||||
csv_parse("message") do |thread|
|
csv_parse("messages") do |thread|
|
||||||
# post
|
# post
|
||||||
|
|
||||||
next unless CATEGORY_IDS.include?(thread.containerid.to_i)
|
next unless CATEGORY_IDS.include?(thread.containerid.to_i)
|
||||||
|
|
Loading…
Reference in a new issue