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