mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Skip batches if all records exist
Update all import scripts to take advantage of all_records_exist?
This commit is contained in:
@@ -101,6 +101,8 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||
|
||||
break if users.size < 1
|
||||
|
||||
next if all_records_exist? :users, users.map {|u| u["id"].to_i}
|
||||
|
||||
create_users(users, total: user_count, offset: offset) do |user|
|
||||
|
||||
{
|
||||
@@ -274,9 +276,10 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||
OFFSET #{offset}
|
||||
SQL
|
||||
|
||||
|
||||
break if topics.size < 1
|
||||
|
||||
next if all_records_exist? :posts, topics.map {|topic| "#{topic["node_id"]} #{topic["id"]}"}
|
||||
|
||||
create_posts(topics, total: topic_count, offset: offset) do |topic|
|
||||
|
||||
category_id = category_id_from_imported_category_id(topic["node_id"])
|
||||
@@ -322,6 +325,8 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||
|
||||
break if posts.size < 1
|
||||
|
||||
next if all_records_exist? :posts, posts.map {|post| "#{post["node_id"]} #{post["root_id"]} #{post["id"]}"}
|
||||
|
||||
create_posts(posts, total: post_count, offset: offset) do |post|
|
||||
raw = post["raw"]
|
||||
next unless topic = topic_lookup_from_imported_post_id("#{post["node_id"]} #{post["root_id"]}")
|
||||
@@ -593,6 +598,8 @@ class ImportScripts::Lithium < ImportScripts::Base
|
||||
|
||||
break if topics.size < 1
|
||||
|
||||
next if all_records_exist? :posts, topics.map {|topic| "pm_#{topic["note_id"]}"}
|
||||
|
||||
create_posts(topics, total: topic_count, offset: offset) do |topic|
|
||||
|
||||
user_id = user_id_from_imported_user_id(topic["sender_user_id"]) || Discourse::SYSTEM_USER_ID
|
||||
|
||||
Reference in New Issue
Block a user