FIX: better error handling in vBulletin importer
This commit is contained in:
parent
7b688aba92
commit
d1608bdfe9
|
@ -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
|
||||||
|
|
|
@ -289,6 +289,7 @@ class ImportScripts::VBulletin < ImportScripts::Base
|
||||||
puts "", "Creating groups membership..."
|
puts "", "Creating groups membership..."
|
||||||
|
|
||||||
Group.find_each do |group|
|
Group.find_each do |group|
|
||||||
|
begin
|
||||||
next if group.automatic
|
next if group.automatic
|
||||||
|
|
||||||
puts "\t#{group.name}"
|
puts "\t#{group.name}"
|
||||||
|
@ -298,15 +299,19 @@ class ImportScripts::VBulletin < ImportScripts::Base
|
||||||
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue