Improvements in importing the lithium pms

This commit is contained in:
Vinoth Kannan 2018-05-18 22:57:15 +05:30
parent d57a17879a
commit ba0dd5889d

View File

@ -430,9 +430,7 @@ class ImportScripts::Lithium < ImportScripts::Base
new_post new_post
else else
message = "Unknown" PluginStoreRow.create(plugin_name: "post_import_log", key: post["unique_id"].to_s, value: "Post 'body' is empty")
message = "Post 'body' is empty" if raw.blank?
PluginStoreRow.create(plugin_name: "post_import_log", key: post["unique_id"].to_s, value: message)
nil nil
end end
end end
@ -467,7 +465,7 @@ class ImportScripts::Lithium < ImportScripts::Base
def import_likes def import_likes
puts "\nimporting likes..." puts "\nimporting likes..."
sql = "select source_id user_id, target_id post_id, row_version created_at from wd.tag_events_score_message" sql = "select source_id user_id, target_id post_id, row_version created_at from tag_events_score_message"
results = mysql_query(sql) results = mysql_query(sql)
puts "loading unique id map" puts "loading unique id map"
@ -697,23 +695,28 @@ class ImportScripts::Lithium < ImportScripts::Base
raw = topic["body"] raw = topic["body"]
msg = { if raw.present?
id: "pm_#{topic["note_id"]}", msg = {
user_id: user_id, id: "pm_#{topic["note_id"]}",
raw: raw, user_id: user_id,
created_at: unix_time(topic["sent_time"]), raw: raw,
import_mode: true created_at: unix_time(topic["sent_time"]),
} import_mode: true
}
unless topic_id unless topic_id
msg[:title] = @htmlentities.decode(topic["subject"]).strip[0...255] msg[:title] = @htmlentities.decode(topic["subject"]).strip[0...255]
msg[:archetype] = Archetype.private_message msg[:archetype] = Archetype.private_message
msg[:target_usernames] = usernames.join(',') msg[:target_usernames] = usernames.join(',')
else
msg[:topic_id] = topic_id
end
msg
else else
msg[:topic_id] = topic_id PluginStoreRow.create(plugin_name: "pm_import_log", key: topic["note_id"].to_s, value: "PM 'body' is empty")
nil
end end
msg
end end
end end