FEATURE: Skip batches if all records exist

Update all import scripts to take advantage of all_records_exist?
This commit is contained in:
Kane York
2015-09-21 16:48:42 -07:00
parent 200ee15991
commit 821124f3fd
20 changed files with 99 additions and 3 deletions

View File

@ -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']