FIX: don't break import when raw can't be preprocessed (vBulletin importer)
This commit is contained in:
parent
e5cad726fd
commit
eecc573fbc
|
@ -210,6 +210,8 @@ class ImportScripts::VBulletin < ImportScripts::Base
|
|||
break if topics.size < 1
|
||||
|
||||
create_posts(topics, total: topic_count, offset: offset) do |topic|
|
||||
raw = preprocess_post_raw(topic["raw"]) rescue nil
|
||||
next if raw.blank?
|
||||
topic_id = "thread-#{topic["threadid"]}"
|
||||
@closed_topic_ids << topic_id if topic["open"] == "0"
|
||||
t = {
|
||||
|
@ -217,7 +219,7 @@ class ImportScripts::VBulletin < ImportScripts::Base
|
|||
user_id: user_id_from_imported_user_id(topic["postuserid"]) || Discourse::SYSTEM_USER_ID,
|
||||
title: @htmlentities.decode(topic["title"]).strip[0...255],
|
||||
category: category_from_imported_category_id(topic["forumid"]).try(:name),
|
||||
raw: preprocess_post_raw(topic["raw"]),
|
||||
raw: raw,
|
||||
created_at: parse_timestamp(topic["dateline"]),
|
||||
visible: topic["visible"].to_i == 1,
|
||||
views: topic["views"],
|
||||
|
@ -231,6 +233,9 @@ class ImportScripts::VBulletin < ImportScripts::Base
|
|||
def import_posts
|
||||
puts "", "importing posts..."
|
||||
|
||||
# make sure `firstpostid` is indexed
|
||||
mysql_query("CREATE INDEX firstpostid_index ON thread (firstpostid)")
|
||||
|
||||
post_count = mysql_query("SELECT COUNT(postid) count FROM post WHERE postid NOT IN (SELECT firstpostid FROM thread)").first["count"]
|
||||
|
||||
batches(BATCH_SIZE) do |offset|
|
||||
|
@ -246,12 +251,14 @@ class ImportScripts::VBulletin < ImportScripts::Base
|
|||
break if posts.size < 1
|
||||
|
||||
create_posts(posts, total: post_count, offset: offset) do |post|
|
||||
raw = preprocess_post_raw(post["raw"]) rescue nil
|
||||
next if raw.blank?
|
||||
next unless topic = topic_lookup_from_imported_post_id("thread-#{post["threadid"]}")
|
||||
p = {
|
||||
id: post["postid"],
|
||||
user_id: user_id_from_imported_user_id(post["userid"]) || Discourse::SYSTEM_USER_ID,
|
||||
topic_id: topic[:topic_id],
|
||||
raw: preprocess_post_raw(post["raw"]),
|
||||
raw: raw,
|
||||
created_at: parse_timestamp(post["dateline"]),
|
||||
hidden: post["visible"].to_i == 0,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue