<< Masa.20101221-update-ch_oddb_org-generics_xls | 2010 | Masa.20101217-update-mail_process-bbmb_ch >>
Run
Result
Success
Success
Plugin: ODDB::XlsExportPlugin Error: NoMethodError Message: undefined method `<=>' for nil:NilClass Backtrace: (druby://localhost:10005) /usr/lib64/ruby/site_ruby/1.8/odba/stub.rb:183:in `_odba_weight' (druby://localhost:10005) /usr/lib64/ruby/site_ruby/1.8/odba/stub.rb:183:in `<=>' (druby://localhost:10005) /home/masa/ywesee/oddb.org/src/model/package.rb:274:in `<=>' (druby://localhost:10005) (eval):2:in `<=>' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:103:in `sort' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:103:in `export_generics' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:98:in `export_generics_xls' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:255:in `call' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:255:in `safe_export' (druby://localhost:10005) /usr/lib64/ruby/1.8/tempfile.rb:172:in `open' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:254:in `safe_export' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:96:in `export_generics_xls' /home/masa/ywesee/oddb.org/src/plugin/xls_export.rb:23:in `export_generics' /home/masa/ywesee/oddb.org/src/util/updater.rb:102:in `export_generics_xls' /home/masa/ywesee/oddb.org/src/util/updater.rb:459:in `call' /home/masa/ywesee/oddb.org/src/util/updater.rb:459:in `wrap_update' /home/masa/ywesee/oddb.org/src/util/updater.rb:100:in `export_generics_xls' /home/masa/ywesee/oddb.org/src/util/updater.rb:273:in `update_bsv_followers' /home/masa/ywesee/oddb.org/src/util/updater.rb:217:in `run' jobs/import_daily:13 /home/masa/ywesee/oddb.org/src/util/job.rb:17:in `call' /home/masa/ywesee/oddb.org/src/util/job.rb:17:in `run' jobs/import_daily:12
Note
Consideration
Experiment
ext/export/src/generics_xls.rb
def export_comparables(package) open("/home/masa/work/test.dat","a"){|o| o.print "getin export_comparables\n"} package.comparables.sort.each { |comp| if(comp.registration.generic?) export_comparable(package, comp) end } @rows end ... def export_generics originals = [] generics = [] comparables = [] @app.each_package { |pac| if(pac.public? && pac.registration.active?) if(pac.registration.original? && (comps = pac.comparables) \ && !comps.empty?) originals.push(pac) comparables.concat(comps) elsif(pac.registration.generic?) generics.push(pac) end end } open("/home/masa/work/test.dat","a"){|o| o.print "check1\n"} open("/home/masa/work/test.dat","a"){|o| o.print "originals.length=", originals.length, "\n"} originals.sort.each { |pac| export_comparables(pac) } open("/home/masa/work/test.dat","a"){|o| o.print "check2\n"} exit
Result
getin GenericXls#export_generics check1 originals.length=944
Note
Consideration
Experiment
ext/export/src/generics_xls.rb
def export_generics open("/home/masa/work/test.dat","w"){|o| o.print "getin GenericXls#export_generics\n"} originals = [] generics = [] comparables = [] @app.each_package { |pac| if(pac.public? && pac.registration.active?) if(pac.registration.original? && (comps = pac.comparables) \ && !comps.empty?) originals.push(pac) comparables.concat(comps) elsif(pac.registration.generic?) generics.push(pac) end end } open("/home/masa/work/test.dat","a"){|o| o.print "check1\n"} open("/home/masa/work/test.dat","a"){|o| o.print "originals.length=", originals.length, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print "originals.class=", originals.class, "\n"} #originals.sort.each { |pac| export_comparables(pac) } originals.each_with_index { |pac,i| open("/home/masa/work/test.dat","a"){|o| o.print "i=", i, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print "pac.class=", pac.class, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print pac.pretty_inspect, "\n"} } ...
Result
masa@masa ~/ywesee/oddb.org $ cat ~/work/test.dat getin GenericXls#export_generics check1 originals.length=944 originals.class=Array i=0 pac.class=ODDB::Package
Note
Experiment
def <=>(other) $count ||= 0 open("/home/masa/work/test.dat","a"){|o| o.print "count=#{$count+=1}\n"} open("/home/masa/work/test.dat","a"){|o| o.print "self.basename=", self.basename, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print "self.dose.to_f=", self.dose.to_f, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print "self.comparable_size.to_f=", self.comparable_size.to_f, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print "other.basename=", other.basename, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print "other.dose.to_f=", other.dose.to_f, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print "other.comparable_size.to_f=", other.comparable_size.to_f, "\n"} [self.basename, self.dose.to_f, self.comparable_size.to_f] <=> \ [other.basename, other.dose.to_f, other.comparable_size.to_f] end
Result
masa@masa ~/ywesee/oddb.org $ cat ~/work/test.dat getin GenericXls#export_generics check1 originals.length=944 originals.class=Array count=1 self.basename=Ciproxin self.dose.to_f=0.0005 self.comparable_size.to_f=20.0 ... count=880 self.basename=nil self.dose.to_f=0.0002 self.comparable_size.to_f=20.0 other.basename=Mucosolvon für Kinder other.dose.to_f=3.0 other.comparable_size.to_f=0.0001
Notes
Next
Experiment
masa@masa ~/work $ ruby -e "p nil <=> 1" -e:1: undefined method `<=>' for nil:NilClass (NoMethodError)
Note
Next
Experiment
ext/export/src/generics_xls.rb#export_generics
def export_generics open("/home/masa/work/test.dat","w"){|o| o.print "getin GenericXls#export_generics\n"} originals = [] generics = [] comparables = [] @app.each_package { |pac| if(pac.public? && pac.registration.active?) if(pac.registration.original? && (comps = pac.comparables) \ && !comps.empty?) originals.push(pac) comparables.concat(comps) elsif(pac.registration.generic?) generics.push(pac) end end } open("/home/masa/work/test.dat","a"){|o| o.print "check1\n"} open("/home/masa/work/test.dat","a"){|o| o.print "originals.length=", originals.length, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print "originals.select{|pac| pac.basename.nil?}.length=", originals.select{|pac| pac.basename.nil?}.length, "\n"} originals.each do |pac| if pac.basename == nil open("/home/masa/work/test.dat","a"){|o| o.print "pac.barcode=", pac.barcode, "\n"} end end
Result
masa@masa ~/ywesee/oddb.org $ cat ~/work/test.dat getin GenericXls#export_generics check1 originals.length=944 originals.select{|pac| pac.basename.nil?}.length=2 pac.barcode=7680570540019 pac.barcode=7680570540033
Notes
Consideration
Next
Experiment
ext/export/src/generics_xls.rb#export_generics
def export_generics originals = [] generics = [] comparables = [] @app.each_package { |pac| if(pac.public? && pac.registration.active?) if(pac.registration.original? && (comps = pac.comparables) \ && !comps.empty?) #&& !comps.empty? && !pac.basename.nil?) originals.push(pac) comparables.concat(comps) elsif(pac.registration.generic?) generics.push(pac) end end } # Some packages cannot be compared because of the package basenames are nil nilpackages = originals.select{|pac| pac.basename.nil?}.map{|pac| [pac.company_name, pac.barcode]} unless nilpackages.empty? error_message = "Package basename is nil. The package is not comparable\n\n" error_message << "Package EAN code: " << nilpackages.join(", ") << "\n" raise StandardError, error_message end
Result
Plugin: ODDB::XlsExportPlugin Error: StandardError Message: Package basename is nil. The package is not comparable. Package EAN code: Merx Pharma (Schweiz) AG, 7680570540019, Merx Pharma (Schweiz) AG, 7680570540033 Backtrace: (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:113:in `export_generics' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:98:in `export_generics_xls' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:255:in `call' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:255:in `safe_export' (druby://localhost:10005) /usr/lib64/ruby/1.8/tempfile.rb:172:in `open' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:254:in `safe_export' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:96:in `export_generics_xls' /home/masa/ywesee/oddb.org/src/plugin/xls_export.rb:23:in `export_generics' /home/masa/ywesee/oddb.org/src/util/updater.rb:102:in `export_generics_xls' /home/masa/ywesee/oddb.org/src/util/updater.rb:459:in `call' /home/masa/ywesee/oddb.org/src/util/updater.rb:459:in `wrap_update' /home/masa/ywesee/oddb.org/src/util/updater.rb:100:in `export_generics_xls' (eval):1:in `_admin' /home/masa/ywesee/oddb.org/src/util/failsafe.rb:9:in `call' /home/masa/ywesee/oddb.org/src/util/failsafe.rb:9:in `failsafe' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1399:in `_admin' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `initialize' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `new' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `_admin' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `__send__' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `perform_without_block' /usr/lib64/ruby/1.8/drb/drb.rb:1516:in `perform' /usr/lib64/ruby/1.8/drb/drb.rb:1590:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1431:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1348:in `initialize' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `new' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `start_service' bin/oddbd:38
Note
Experiment
ext/export/src/generics_xls.rb#export_generics
def export_generics open("/home/masa/work/test.dat","w"){|o| o.print "getin GenericXls#export_generics\n"} originals = [] generics = [] comparables = [] @app.each_package { |pac| if(pac.public? && pac.registration.active? && !pac.basename.nil?) if(pac.registration.original? && (comps = pac.comparables) \ && !comps.empty?) originals.push(pac) comparables.concat(comps) elsif(pac.registration.generic?) generics.push(pac) end end }
Result
Plugin: ODDB::XlsExportPlugin Error: ArgumentError Message: comparison of ODBA::Stub with ODBA::Stub failed Backtrace: (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:77:in `sort' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:77:in `export_comparables' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:118:in `export_generics' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:118:in `each' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/generics_xls.rb:118:in `export_generics' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:98:in `export_generics_xls' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:255:in `call' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:255:in `safe_export' (druby://localhost:10005) /usr/lib64/ruby/1.8/tempfile.rb:172:in `open' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:254:in `safe_export' (druby://localhost:10005) /home/masa/ywesee/oddb.org/ext/export/src/odba_exporter.rb:96:in `export_generics_xls' /home/masa/ywesee/oddb.org/src/plugin/xls_export.rb:23:in `export_generics' /home/masa/ywesee/oddb.org/src/util/updater.rb:102:in `export_generics_xls' /home/masa/ywesee/oddb.org/src/util/updater.rb:459:in `call' /home/masa/ywesee/oddb.org/src/util/updater.rb:459:in `wrap_update' /home/masa/ywesee/oddb.org/src/util/updater.rb:100:in `export_generics_xls' (eval):1:in `_admin' /home/masa/ywesee/oddb.org/src/util/failsafe.rb:9:in `call' /home/masa/ywesee/oddb.org/src/util/failsafe.rb:9:in `failsafe' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1399:in `_admin' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `initialize' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `new' /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:1397:in `_admin' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `__send__' /usr/lib64/ruby/1.8/drb/drb.rb:1556:in `perform_without_block' /usr/lib64/ruby/1.8/drb/drb.rb:1516:in `perform' /usr/lib64/ruby/1.8/drb/drb.rb:1590:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `loop' /usr/lib64/ruby/1.8/drb/drb.rb:1586:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1582:in `main_loop' /usr/lib64/ruby/1.8/drb/drb.rb:1431:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `start' /usr/lib64/ruby/1.8/drb/drb.rb:1428:in `run' /usr/lib64/ruby/1.8/drb/drb.rb:1348:in `initialize' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `new' /usr/lib64/ruby/1.8/drb/drb.rb:1628:in `start_service' bin/oddbd:38
Note
def <=>(other) $count ||= 0 open("/home/masa/work/test.dat","a"){|o| o.print "count=#{$count+=1}\n"} open("/home/masa/work/test.dat","a"){|o| o.print "self.basename=", self.basename, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print "self.dose.to_f=", self.dose.to_f, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print "self.comparable_size.to_f=", self.comparable_size.to_f, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print "other.basename=", other.basename, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print "other.dose.to_f=", other.dose.to_f, "\n"} open("/home/masa/work/test.dat","a"){|o| o.print "other.comparable_size.to_f=", other.comparable_size.to_f, "\n"} [self.basename, self.dose.to_f, self.comparable_size.to_f] <=> \ [other.basename, other.dose.to_f, other.comparable_size.to_f] end
Result
masa@masa ~/ywesee/oddb.org $ cat ~/work/test.dat ... count=27443 self.basename=Treupel Dolo Ibuprofen self.dose.to_f=0.0002 self.comparable_size.to_f=10.0 other.basename=nil other.dose.to_f=0.0002 other.comparable_size.to_f=10.0
Note
Experiment (skip the packages that have 'nil' basename)
ext/export/src/generics_xls.rb#export_generics
def export_generics originals = [] generics = [] comparables = [] @app.each_package { |pac| # if(pac.public? && pac.registration.active?) if(pac.public? && pac.registration.active? && !pac.basename.nil? && pac.comparables.select{|pack| pack.basename.nil?}.empty?) if(pac.registration.original? && (comps = pac.comparables) \ && !comps.empty?) originals.push(pac) comparables.concat(comps) elsif(pac.registration.generic?) generics.push(pac) end end } ...
Result
...looks running without error
Notes
Experiment
ext/export/src/generics_xls.rb#export_generics
def export_generics originals = [] generics = [] comparables = [] @app.each_package { |pac| if(pac.public? && pac.registration.active?) #if(pac.public? && pac.registration.active? && !pac.basename.nil? && pac.comparables.select{|pack| pack.basename.nil?}.empty?) if(pac.registration.original? && (comps = pac.comparables) \ && !comps.empty?) originals.push(pac) comparables.concat(comps) elsif(pac.registration.generic?) generics.push(pac) end end } # Check Packages # Some packages cannot be compared if package basename is nil open("/home/masa/work/test.dat","a"){|o| o.print "originals.length=", originals.length,"\n"} nilpackages = originals.select{|pac| pac.basename.nil?}.map{|pac| [pac.company_name, pac.barcode]} originals.each do |pac| open("/home/masa/work/test.dat","a"){|o| o.print "pac.comparables.length=", pac.comparables.length,"\n"} open("/home/masa/work/test.dat","a"){|o| o.print "pac.comparables.select{|pack| pack.basename.nil?}.length=", pac.comparables.select{|pack| pack.basename.nil?}.length,"\n"} open("/home/masa/work/test.dat","a"){|o| o.print "pac.comparables.select{|pack| pack.basename.nil?}.map{|pack| pack.barcode}=", pac.comparables.select{|pack| pack.basename.nil?}.map{|pack| pack.barcode},"\n"} end
Result
... pac.comparables.length=9 pac.comparables.select{|pack| pack.basename.nil?}.length=1 pac.comparables.select{|pack| pack.basename.nil?}.map{|pack| pack.barcode}=7680570540019 pac.comparables.length=13 pac.comparables.select{|pack| pack.basename.nil?}.length=1 pac.comparables.select{|pack| pack.basename.nil?}.map{|pack| pack.barcode}=7680570540033 ...
Note
Next
Make test case template
ext/exporter/test/test_generics_xls.rb
#!/usr/bin/env ruby # Odba::Exporter::TestGenericsXls -- oddb -- 20.12.2010 -- mhatakeyama@ywesee.com require 'flexmock' require 'test/unit' module ODDB module OdbaExporter class TestGenericXls < Test::Unit::TestCase include FlexMock::TestCase def test_export_generics assert(true) end end end end
Confirm test passes
masa@masa ~/ywesee/oddb.org/ext/export $ ruby test/test_generics_xls.rb Loaded suite test/test_generics_xls Started . Finished in 0.000159 seconds. 1 tests, 1 assertions, 0 failures, 0 errors