Moved ActiveRecord::Base.transaction to lower scope.

This commit is contained in:
Martin Edenhofer 2015-05-01 13:57:49 +02:00
parent cc641407ea
commit 8850bf299b

View file

@ -323,29 +323,41 @@ module Import::OTRS2
# create states
states = load('State')
ActiveRecord::Base.transaction do
state(states)
end
# create priorities
priorities = load('Priority')
ActiveRecord::Base.transaction do
priority(priorities)
end
# create groups
queues = load('Queue')
ActiveRecord::Base.transaction do
ticket_group(queues)
end
# get agents groups
ActiveRecord::Base.transaction do
groups = load('Group')
end
# get agents roles
roles = load('Role')
# create agents
users = load('User')
ActiveRecord::Base.transaction do
user(users, groups, roles, queues)
end
# create organizations
organizations = load('Customer')
ActiveRecord::Base.transaction do
organization(organizations)
end
# create customers
count = 0
@ -517,8 +529,6 @@ module Import::OTRS2
result.each {|record|
ActiveRecord::Base.transaction do
# cleanup values
_cleanup(record)
@ -690,6 +700,7 @@ module Import::OTRS2
}
#puts "HS: #{record['History'].inspect}"
ActiveRecord::Base.transaction do
record['History'].each { |history|
if history['HistoryType'] == 'NewTicket'
#puts "HS.add( #{history.inspect} )"
@ -796,9 +807,9 @@ module Import::OTRS2
created_by_id: history['CreateBy']
)
end
}
end
}
}
end
# sync ticket states