Class: KMExport::Reimporter
- Inherits:
-
Object
- Object
- KMExport::Reimporter
- Defined in:
- lib/reimporter.rb
Instance Method Summary collapse
Instance Method Details
#send_line_to_KM(line) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/reimporter.rb', line 42 def send_line_to_KM(line) identity = line.delete("_p") second_identity = line.delete("_p2") event = line.delete("_n") line["_d"] = 1 KMTS.alias(identity,second_identity) if second_identity KMTS.record(identity,event,line) if event KMTS.set(identity,line) unless event || second_identity end |
#send_to_KM(json, key) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/reimporter.rb', line 18 def send_to_KM(json, key) pool = 10 threads = [] queue = JSONQueue.new({file: json, counter: 0}) queue.add_to_queue pool.times do threads << Thread.new do KMTS.init(key, :use_cron => false, :to_stderr => true) until queue.empty? work_unit = queue.pop(true) rescue nil send_line_to_KM(work_unit) end end end threads.each { |t| t.join } STDOUT.print('Reimportation process completed.') end |