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

@ -73,7 +73,7 @@ class ImportScripts::MyAskBot < ImportScripts::Base
LIMIT #{BATCH_SIZE}
OFFSET #{offset}
SQL
)
)
break if tags.ntuples() < 1
tags.each do |tag|
tid = tag["thread_id"].to_i
@ -110,6 +110,8 @@ class ImportScripts::MyAskBot < ImportScripts::Base
break if users.ntuples() < 1
next if all_records_exist? :users, users.map {|u| u["id"].to_i}
create_users(users, total: total_count, offset: offset) do |user|
{
id: user["id"],
@ -153,6 +155,8 @@ class ImportScripts::MyAskBot < ImportScripts::Base
break if posts.ntuples() < 1
next if all_records_exist? :posts, posts.map {|p| p["id"].to_i}
create_posts(posts, total: post_count, offset: offset) do |post|
pid = post["id"]
tid = post["thread_id"].to_i
@ -206,6 +210,8 @@ class ImportScripts::MyAskBot < ImportScripts::Base
break if posts.ntuples() < 1
next if all_records_exist? :posts, posts.map {|p| p["id"].to_i}
create_posts(posts, total: post_count, offset: offset) do |post|
tid = post["thread_id"].to_i
next unless thread = @thread_parents[tid]
@ -267,4 +273,4 @@ class ImportScripts::MyAskBot < ImportScripts::Base
end
end
ImportScripts::MyAskBot.new.perform
ImportScripts::MyAskBot.new.perform