<< | Index | >>
Log (oddbd console)
WARNING: nonstandard use of \' in a string literal LINE 3: AND search_term = 'fraxiparine multi, 9\'500 u.i. an... ^ HINT: Use '' to write quotes in strings, or use the escape string syntax (E'...'). /usr/lib64/ruby/site_ruby/1.8/odba/cache.rb:324: [BUG] Segmentation fault ruby 1.8.6 (2009-06-08) [x86_64-linux] Abgebrochen
bin/admin
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> Updater.new(self).update_package_trade_status_by_swissindex -> connection closed
Note
New Process
Updated src/plugin/swissindex.rb#update_package_trade_status
def update_package_trade_status out_of_trade_true_list = [] out_of_trade_false_list = [] update_pharmacode_list = [] log = open('/home/masa/work/result_update_swissindex_log.dat', 'w') count = 1 start_time = Time.now @app.each_package do |pack| SWISSINDEX_PHARMA_SERVER.session do |swissindex| if item = swissindex.search(pack.barcode.to_s) # not change flag # but just save the list out_of_trade_false_list << pack # check pharmacode if pack.pharmacode and pharmacode = item[:phar] update_pharmacode_list << [pack, pharmacode] end else out_of_trade_true_list << pack end sleep(0.05) end estimate = (Time.now - start_time) * @app.package_count / count log.print count " / ", @app.package_count, "\t", pack.barcode, "\t estimate: ", "%.2f" % (estimate/60), " [m] ", "%.2f" % (estimate/60/60), " [h]\n" count += 1 end log.close # for debug open('/home/masa/work/result_update_swissindex_package_trade_status.dat', 'w') do |out| out.print "out_of_trade true list\n" out.print out_of_trade_true_list.map{|x| x.barcode}.join("\n"), "\n" out.print "\n" out.print "out_of_trade false list\n" out.print out_of_trade_false_list.map{|x| x.barcode}.join("\n"), "\n" out.print "\n" out.print "updte_pharmacode_list\n" out.print update_pharmacode_list.map{|x, y| x.barcode.to_s + ", " + y.to_s}.join("\n"), "\n" end # # change flag # #out_of_trade_true_list << @app.package('883519') #out_of_trade_false_list << @app.package('883519') open('/home/masa/work/result_update_swissindex_out_of_trade_true.dat', 'w') do |out| out_of_trade_true_list.each do |pack| unless pack.out_of_trade @app.update(pack.pointer, {:out_of_trade => true}, :refdata) out.print pack.barcode, "\n" end end end open('/home/masa/work/result_update_swissindex_out_of_trade_false.dat', 'w') do |out| out_of_trade_false_list.each do |pack| if pack.out_of_trade @app.update(pack.pointer, {:out_of_trade => false, :refdata_override => false}, :refdata) out.print pack.barcode, "\n" end end end # # update pharmacode # open('/home/masa/work/result_update_swissindex_pharmacode.dat', 'w') do |out| update_pharmacode_list.each do |pack, pharmacode| @app.update(pack.pointer, {:pharmacode => pharmacode}, :bag) out.print pack.barcode, "\t", pharmacode, "\n" end end end
Note
Run
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> Updater.new(self).update_package_trade_status_by_swissindex
Add a process
Updated src/plugin/swissindex.rb#update_package_trade_status
def update_package_trade_status out_of_trade_true_list = [] out_of_trade_false_list = [] update_pharmacode_list = [] delete_pharmacode_list = [] log = open('/home/masa/work/result_update_swissindex_log.dat', 'w') count = 1 start_time = Time.now @app.each_package do |pack| SWISSINDEX_PHARMA_SERVER.session do |swissindex| if item = swissindex.search(pack.barcode.to_s) # not change flag # but just save the list out_of_trade_false_list << pack # check pharmacode if !pack.pharmacode and pharmacode = item[:phar] update_pharmacode_list << [pack, pharmacode] end else out_of_trade_true_list << pack # check pharmacode if pack.pharmacode delete_pharmacode_list << pack end end sleep(0.05) end estimate = (Time.now - start_time) * @app.package_count / count log.print count, " / ", @app.package_count, "\t", pack.barcode, "\t estimate: ", "%.2f" % (estimate/60), " [m] ", "%.2f" % (estimate/60/60), " [h]" rest = estimate - (Time.now - start_time) log.print "in: ", "%.2f" % (rest/60), " [m] ", "%.2f" % (rest/60/60), " [h]\n" count += 1 end log.close # for debug open('/home/masa/work/result_update_swissindex_package_trade_status.dat', 'w') do |out| out.print "out_of_trade true list\n" out.print out_of_trade_true_list.map{|x| x.barcode}.join("\n"), "\n" out.print "\n" out.print "out_of_trade false list\n" out.print out_of_trade_false_list.map{|x| x.barcode}.join("\n"), "\n" out.print "\n" out.print "updte_pharmacode_list\n" out.print update_pharmacode_list.map{|x, y| x.barcode.to_s + ", " + y.to_s}.join("\n"), "\n" out.print "\n" out.print "delete_pharmacode_list\n" out.print delete_pharmacode_list.map{|x| x.barcode}.join("\n"), "\n" end # # change flag # #out_of_trade_true_list << @app.package('883519') #out_of_trade_false_list << @app.package('883519') open('/home/masa/work/result_update_swissindex_out_of_trade_true.dat', 'w') do |out| out_of_trade_true_list.each do |pack| unless pack.out_of_trade @app.update(pack.pointer, {:out_of_trade => true}, :refdata) out.print pack.barcode, "\n" end end end open('/home/masa/work/result_update_swissindex_out_of_trade_false.dat', 'w') do |out| out_of_trade_false_list.each do |pack| if pack.out_of_trade @app.update(pack.pointer, {:out_of_trade => false, :refdata_override => false}, :refdata) out.print pack.barcode, "\n" end end end # # update pharmacode # open('/home/masa/work/result_update_swissindex_pharmacode.dat', 'w') do |out| out.print "update_pharmacode\n" update_pharmacode_list.each do |pack, pharmacode| @app.update(pack.pointer, {:pharmacode => pharmacode}, :bag) out.print pack.barcode, "\t", pharmacode, "\n" end out.print "\ndelete_pharmacode\n" delete_pharmacode_list.each do |pack| @app.update(pack.pointer, {:pharmacode => nil}, :bag) out.print pack.barcode, "\t", pharmacode, "\n" end end end
Note
total_iteration = 100 start_time = Time.now total_iteration.times do |i| sleep rand elapsed_time = Time.now - start_time estimate_time = elapsed_time * total_iteration / (i+1) print i, "\tEstimate time: ", "%.2f" % estimate_time, " [s]\n" end end_time = Time.now print "Actual time: ", end_time - start_time, " [s]\n"
Result
how to make a graph from the data above
gnuplot make_graph.20110506.txt
Note