FIX: better error handling in vBulletin importer

This commit is contained in:
Régis Hanol 2014-09-08 11:02:54 +02:00
parent 7b688aba92
commit d1608bdfe9
2 changed files with 18 additions and 13 deletions

View File

@ -213,7 +213,7 @@ class CookedPostProcessor
Oneboxer.apply(@doc) { |url| Oneboxer.onebox(url, args) } Oneboxer.apply(@doc) { |url| Oneboxer.onebox(url, args) }
# make sure we grab dimensions for oneboxed images # make sure we grab dimensions for oneboxed images
oneboxed_images.each { |img| puts "image: #{img["src"]}"; limit_size!(img) } oneboxed_images.each { |img| limit_size!(img) }
end end
def optimize_urls def optimize_urls

View File

@ -289,24 +289,29 @@ class ImportScripts::VBulletin < ImportScripts::Base
puts "", "Creating groups membership..." puts "", "Creating groups membership..."
Group.find_each do |group| Group.find_each do |group|
next if group.automatic begin
next if group.automatic
puts "\t#{group.name}" puts "\t#{group.name}"
next if GroupUser.where(group_id: group.id).count > 0 next if GroupUser.where(group_id: group.id).count > 0
user_ids_in_group = User.where(primary_group_id: group.id).pluck(:id).to_a user_ids_in_group = User.where(primary_group_id: group.id).pluck(:id).to_a
next if user_ids_in_group.size == 0 next if user_ids_in_group.size == 0
values = user_ids_in_group.map { |user_id| "(#{group.id}, #{user_id})" }.join(",") values = user_ids_in_group.map { |user_id| "(#{group.id}, #{user_id}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)" }.join(",")
User.exec_sql <<-SQL User.exec_sql <<-SQL
BEGIN; BEGIN;
INSERT INTO group_users (group_id, user_id) VALUES #{values}; INSERT INTO group_users (group_id, user_id, created_at, updated_at) VALUES #{values};
COMMIT; COMMIT;
SQL SQL
Group.reset_counters(group.id, :group_users) Group.reset_counters(group.id, :group_users)
rescue Exception => e
puts e.message
puts e.backtrace.join("\n")
end
end end
end end