From 3b119dac6dfb28253f643cff81594c992ad1b75d Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 6 Jul 2016 10:58:43 -0400 Subject: [PATCH] FIX: importer performance of update_tl0, and give feedback during vanilla_mysql's create_permalinks --- script/import_scripts/base.rb | 4 ++-- script/import_scripts/vanilla_mysql.rb | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/script/import_scripts/base.rb b/script/import_scripts/base.rb index e7829a270..f0968c212 100644 --- a/script/import_scripts/base.rb +++ b/script/import_scripts/base.rb @@ -705,9 +705,9 @@ class ImportScripts::Base total_count = User.count progress_count = 0 - User.find_each do |user| + User.includes(:user_stat).find_each do |user| begin - user.change_trust_level!(0) if Post.where(user_id: user.id).count == 0 + user.update_columns(trust_level: 0) if user.trust_level > 0 && user.post_count == 0 rescue Discourse::InvalidAccess nil end diff --git a/script/import_scripts/vanilla_mysql.rb b/script/import_scripts/vanilla_mysql.rb index 3001149b2..f82a489f0 100644 --- a/script/import_scripts/vanilla_mysql.rb +++ b/script/import_scripts/vanilla_mysql.rb @@ -364,6 +364,7 @@ class ImportScripts::VanillaSQL < ImportScripts::Base ucf = u.custom_fields if ucf && ucf["import_id"] && ucf["import_username"] Permalink.create( url: "profile/#{ucf['import_id']}/#{ucf['import_username']}", external_url: "/users/#{u.username}" ) rescue nil + print '.' end end @@ -378,6 +379,7 @@ class ImportScripts::VanillaSQL < ImportScripts::Base else Permalink.create( url: "discussion/comment/#{id}", post_id: post.id ) rescue nil end + print '.' end end end