mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +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:
@ -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
|
||||
|
Reference in New Issue
Block a user