mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
FEATURE: Skip batches if all records exist
Update all import scripts to take advantage of all_records_exist?
This commit is contained in:
@ -69,6 +69,7 @@ class ImportScripts::Mbox < ImportScripts::Base
|
||||
batches(BATCH_SIZE) do |offset|
|
||||
users = user_keys[offset..offset+BATCH_SIZE-1]
|
||||
break if users.nil?
|
||||
next if all_records_exist? :users, users
|
||||
|
||||
create_users(users, total: total_count, offset: offset) do |email|
|
||||
{
|
||||
@ -99,6 +100,8 @@ class ImportScripts::Mbox < ImportScripts::Base
|
||||
topics = all_topics[offset..offset+BATCH_SIZE-1]
|
||||
break if topics.nil?
|
||||
|
||||
next if all_records_exist? :posts, topics.map {|t| t['id'].to_i}
|
||||
|
||||
create_posts(topics, total: topic_count, offset: offset) do |t|
|
||||
raw_email = File.read(t['file'])
|
||||
receiver = Email::Receiver.new(raw_email, skip_sanity_check: true)
|
||||
@ -136,6 +139,8 @@ class ImportScripts::Mbox < ImportScripts::Base
|
||||
posts = replies[offset..offset+BATCH_SIZE-1]
|
||||
break if posts.nil?
|
||||
|
||||
next if all_records_exist? :posts, posts.map {|p| p['id'].to_i}
|
||||
|
||||
create_posts(posts, total: post_count, offset: offset) do |p|
|
||||
parent_id = p['topic']
|
||||
id = p['id']
|
||||
|
Reference in New Issue
Block a user