Moved to threads for import.
This commit is contained in:
parent
a1f6a3afdc
commit
36d0220183
|
@ -83,11 +83,25 @@ module Import::OTRS
|
||||||
# customer
|
# customer
|
||||||
|
|
||||||
result = JSON.parse( response.body )
|
result = JSON.parse( response.body )
|
||||||
while true
|
result = result.reverse
|
||||||
ticket_ids = result.pop(20)
|
|
||||||
return if ticket_ids.empty?
|
thread_count = 8
|
||||||
self.ticket(ticket_ids)
|
threads = {}
|
||||||
end
|
(1..thread_count).each {|thread|
|
||||||
|
threads[thread] = Thread.new {
|
||||||
|
sleep thread * 3
|
||||||
|
puts "Started import thread# #{thread}..."
|
||||||
|
while true
|
||||||
|
ticket_ids = result.pop(20)
|
||||||
|
return if ticket_ids.empty?
|
||||||
|
self.ticket(ticket_ids)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(1..thread_count).each {|thread|
|
||||||
|
threads[thread].join
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -650,12 +664,14 @@ module Import::OTRS
|
||||||
done = false
|
done = false
|
||||||
_set_valid(user)
|
_set_valid(user)
|
||||||
|
|
||||||
|
role = Role.lookup( :name => 'Customer' )
|
||||||
|
|
||||||
# get new attributes
|
# get new attributes
|
||||||
user_new = {
|
user_new = {
|
||||||
:created_by_id => 1,
|
:created_by_id => 1,
|
||||||
:updated_by_id => 1,
|
:updated_by_id => 1,
|
||||||
:source => 'OTRS Import',
|
:source => 'OTRS Import',
|
||||||
:role_ids => [3],
|
:role_ids => [role.id],
|
||||||
}
|
}
|
||||||
map.each { |key,value|
|
map.each { |key,value|
|
||||||
if user[key.to_s]
|
if user[key.to_s]
|
||||||
|
|
Loading…
Reference in a new issue