view · edit · sidebar · attach · print · history

Index>

20140706-Fix-undefined-method-toI-for-DateTime

Summary

  • Fix import fachinfo for non existing iksnr
  • Fix print button in Rezeptansicht. Add it to the watir tests

Commits

Index

Keep in Mind
  • Fix dojo error http://www.sitepen.com/blog/2012/10/31/debugging-dojo-common-error-messages/#forgot-dom-ready
  • I removed on May-27 tests for ix_registrationss, fix_sequences, fix_compositions, fix_packages from test/test_plugin/swissmedic.rb,as he could not find any references for them in the src code. Did I erroneously remove stuff when cleaning up the swissmedic import earlier?
  • The whole test for older/newer Packages must be adapted to xlsx. One must compare the rows (e.g. by creating csv files) and do the same stuff in xlsx!
  • One unit-test for searchbar fails and might be a clue why searching does not work correctly.
  • Added two skip in test/test_plugin/rss.rb. Why does the mocking not work there anymore?
  • Make ext/swissindex/test/test_swissindex.rb and skipping tests in migel-gem pass.

---

Fix undefined method `to_i' for #<DateTime:0x000000cbb801c0> in import_daily

Got the following error message in import_daily

Plugin: ODDB::SwissmedicPlugin
Error: NoMethodError
Message: undefined method `to_i' for #<DateTime:0x000000cbb801c0>
Backtrace:
/usr/local/lib/ruby/gems/1.9.1/gems/swissmedic-diff-0.1.7/lib/compatibility.rb:29:in `date_cell'
/usr/local/lib/ruby/gems/1.9.1/gems/swissmedic-diff-0.1.7/lib/swissmedic-diff.rb:274:in `_comparable'
/usr/local/lib/ruby/gems/1.9.1/gems/swissmedic-diff-0.1.7/lib/swissmedic-diff.rb:220:in `block in rows_diff'
/usr/local/lib/ruby/gems/1.9.1/gems/swissmedic-diff-0.1.7/lib/swissmedic-diff.rb:218:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/swissmedic-diff-0.1.7/lib/swissmedic-diff.rb:218:in `each_with_index'
/usr/local/lib/ruby/gems/1.9.1/gems/swissmedic-diff-0.1.7/lib/swissmedic-diff.rb:218:in `rows_diff'
/var/www/oddb.org/src/plugin/swissmedic.rb:422:in `rows_diff'
/usr/local/lib/ruby/gems/1.9.1/gems/swissmedic-diff-0.1.7/lib/swissmedic-diff.rb:136:in `block in diff'
/usr/local/lib/ruby/gems/1.9.1/gems/swissmedic-diff-0.1.7/lib/swissmedic-diff.rb:312:in `block in each_valid_row'
/usr/local/lib/ruby/gems/1.9.1/gems/rubyXL-1.2.10/lib/rubyXL/worksheet.rb:31:in `block in each'
/usr/local/lib/ruby/gems/1.9.1/gems/rubyXL-1.2.10/lib/rubyXL/worksheet.rb:31:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/rubyXL-1.2.10/lib/rubyXL/worksheet.rb:31:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/swissmedic-diff-0.1.7/lib/swissmedic-diff.rb:300:in `each_valid_row'
/usr/local/lib/ruby/gems/1.9.1/gems/swissmedic-diff-0.1.7/lib/swissmedic-diff.rb:110:in `diff'
/var/www/oddb.org/src/plugin/swissmedic.rb:63:in `update'
/var/www/oddb.org/src/util/updater.rb:399:in `block in update_swissmedic'
/var/www/oddb.org/src/util/updater.rb:501:in `call'
/var/www/oddb.org/src/util/updater.rb:501:in `wrap_update'
/var/www/oddb.org/src/util/updater.rb:397:in `update_swissmedic'
/var/www/oddb.org/src/util/updater.rb:197:in `run'
jobs/import_daily:13:in `block in <module:Util>'
/var/www/oddb.org/src/util/job.rb:40:in `call'
/var/www/oddb.org/src/util/job.rb:40:in `run'
jobs/import_daily:12:in `<module:Util>'
jobs/import_daily:11:in `<module:ODDB>'
jobs/import_daily:10:in `<main>'

In log/oddb/debug/2014/07.log found

 
2014-07-07 07:21:10 CESTlog notify Fach- und Patienteninfo Updates (swissmedicinfo.ch): sent mail  
2014-07-07 07:21:10 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb: 276 updated download.size is 2678294./var/www/oddb.org/data/xls/Packungen-2014.07.07.xlsx now 2678294 bytes != /var/www/oddb.org/data/xls/Packungen-latest.xlsx 2672682  
2014-07-07 07:21:10 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb: 53 update target "/var/www/oddb.org/data/xls/Packungen-2014.07.07.xlsx"2678294 bytes. Latest /var/www/oddb.org/data/xls/Packungen-latest.xlsx 2672682 bytes  
2014-07-07 07:21:11 +0200: /var/www/oddb.org/src/plugin/swissmedic.rb: 281 skip writing /var/www/oddb.org/data/xls/Präparateliste-2014.07.07.xlsx as /var/www/oddb.org/data/xls/Präparateliste-latest.xlsx is 2228737 bytes. Returning latest
2014-07-07 07:28:32 CESTlog notify Error: swissmedic: start outgoing process ["log"]
2014-07-07 07:28:32 CESTUtil.send_mail list_and_recipients ["log"]  
2014-07-07 07:28:32 CEST Util.log_and_deliver_mail to=["ngiger@ywesee.com", "zdavatz@ywesee.com"] subject ch.ODDB.org Report - Error: swissmedic - 07/2014 size Plugin: ODDB::Swiss

Reproduced the error locally. Tried changing /usr/local/lib/ruby/gems/1.9.1/gems/swissmedic-diff-0.1.7/lib/compatibility.rb:29 to

        if data.value.class.to_s == 'DateTime'
                puts "data is_a RubyXL::Cell and value #{data.value.class} is_a? Date #{data.value.is_a?(Date)} DateTime #{data.value.is_a?(DateTime)}"
           return Date.new(1899,12,30)+data.to_date.value.to_i
        else
          return Date.new(1899,12,30)+data.value.to_i if data.is_a?(RubyXL::Cell)
        end

Now we get further, but have the following error

Plugin: ODDB::SwissmedicPlugin
Error: TypeError
Message: '2014-06-06'(DateTime) should be NilClass or Date
Backtrace:
/var/www/oddb.org/src/util/persistence.rb:121:in `block (2 levels) in define_check_class_methods'
/var/www/oddb.org/src/util/persistence.rb:87:in `block in update_values'
/var/www/oddb.org/src/util/persistence.rb:84:in `each'
/var/www/oddb.org/src/util/persistence.rb:84:in `update_values'
/var/www/oddb.org/src/util/persistence.rb:260:in `issue_update'
/var/www/oddb.org/src/util/oddbapp.rb:133:in `block in update'
/var/www/oddb.org/src/util/failsafe.rb:10:in `call'
/var/www/oddb.org/src/util/failsafe.rb:10:in `failsafe'
/var/www/oddb.org/src/util/oddbapp.rb:131:in `update'
/var/www/oddb.org/src/util/oddbapp.rb:1575:in `update'
/var/www/oddb.org/src/plugin/swissmedic.rb:830:in `update_sequence'
/var/www/oddb.org/src/plugin/swissmedic.rb:764:in `block in update_registrations'
/var/www/oddb.org/src/plugin/swissmedic.rb:760:in `each'
/var/www/oddb.org/src/plugin/swissmedic.rb:760:in `update_registrations'
/var/www/oddb.org/src/plugin/swissmedic.rb:70:in `update'
/var/www/oddb.org/src/util/updater.rb:406:in `block in update_swissmedic'
/var/www/oddb.org/src/util/updater.rb:508:in `call'
/var/www/oddb.org/src/util/updater.rb:508:in `wrap_update'
/var/www/oddb.org/src/util/updater.rb:404:in `update_swissmedic'
/var/www/oddb.org/src/util/updater.rb:188:in `run'
jobs/import_daily:34:in `block in <module:Util>'
/var/www/oddb.org/src/util/job.rb:40:in `call'
/var/www/oddb.org/src/util/job.rb:40:in `run'
jobs/import_daily:12:in `<module:Util>'
jobs/import_daily:11:in `<module:ODDB>'
jobs/import_daily:10:in `<main>'

One of the problem is that a DateTime object is also a Date.object. Rerunning import and debugging, which accessor has problems dealing with the DateTime. I think it might be easier to relax the model to accept a DateTime, too like in src/model/registration.rb: :registration_date => ["DateTime","Date"]. Adding a dump of each row and restarting import_swissmedic again.

Now I get the error Message: sequence_date= '2014-06-02'(DateTime) should be NilClass or Datex

Copied downloads Packungen.xlsx to test/data/Packungen_2014_small.xlsx in swissmedic-diff. Now the unit tests take almost 10 minutes to complete, but show the error. Adding a workaroung and some debugging output to catch the failing rows. Now I see output like

Rescue in Spreadsheet.date_cell for idx 7 ["00274", "01", (4,2): Cardio-Pulmo-Rénal Sérocytol, suppositoire, datatype = s, style_index = 6, (4,3): Sérolab, société anonyme, datatype = s, style_index = 4, (4,4): 08.07., datatype = s, style_index = 4, (4,5): J06AA, datatype = s, style_index = 4, (4,6): Blutprodukte, datatype = s, style_index = 4, (4,7): 40294, datatype = , style_index = 23, (4,8): 40294, datatype = , style_index = 23, (4,9): 42119, datatype = , style_index = 23, "001", (4,11): 3, datatype = s, style_index = 4, (4,12): Suppositorien, datatype = s, style_index = 5, (4,13): B, datatype = s, style_index = 6, (4,14): globulina equina (immunisé avec coeur, tissu pulmonaire, reins de porcins), datatype = s, style_index = 6, (4,15): globulina equina (immunisé avec coeur, tissu pulmonaire, reins de porcins) 8 mg, propylenglycolum, conserv.: E 216, E 218, excipiens pro suppositorio., datatype = s, style_index = 6, (4,16): Traitement immunomodulant  selon le Dr Thomas

Now when looking at the field "Erstzul.datum Präp." of row 7 00277 Coeur-Vaisseaux Sérocytol, suppositoire I had before in the unit-tests "26.04.2010" whereas now it displays "26.04.10" and has as "40294" as value to edit. Trying to copy a few lines from the new Packungen.xlsx resulted in RuntimeError: invalid file when running rake test. Trying to generate the small file from the current xlsx resulted in the same error. Therefore it triggered an error either in the RubyXL

Error comes with

Updating 61249 02 sequence_date Imnovid 2mg Hartkapseln -> #<DateTime: 2014-06-02T00:00:00+00:00 ((2456811j,0s,0n),+0s,2299161j)> todate #<Date: 2014-06-02 ((2456811j,0s,0n),+0s,2299161j)> DateTime -> Date

Fixed and added unit test with commits:

Trying to load rubyXL when running sudo -u apache /usr/local/bin/ruby bin/oddbd resulted in

/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- rubyXL (LoadError)
        from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:55:in `require'
        from bin/oddbd:7:in `<main>'

Tried a long time till I figured out that I could provoke the same error when running as local user if I move the $HOME/.gem directory to $HOME/.gem.unused. Using gem env to analyse the difference.

Calling

sudo chown -R apache:apache /usr/local/lib/ruby/gems/1.9.1
sudo -u apache /usr/local/bin/gem install rubyXL
sudo -u apache /usr/local/bin/gem content rubyXL
fixed the problem.

Pushed commit Updated to use rubyzip >= 1.0.0. Now I am able to start oddbd without problem.

Reloading DB dump of last week and restarting import_daily.

Got the following error [# Opened /var/www/oddb.org/log/oddb/debug/2014/07.log

WARNING: RubyXL::Worksheet is not aware what to do with RubyXL::GenericStorageObject

WARNING: RubyXL::Worksheet is not aware what to do with RubyXL::GenericStorageObject /var/www/oddb.org/src/util/mail.rb: Configured email using /var/www/oddb.org/etc/oddb.yml @cfg is now "smtp.gmail.com" 587 "ngiger@ywesee.com" Util.log_and_deliver_mail to=["ngiger@ywesee.com"] subject ch.ODDB.org Report - Error: swissmedic - 07/2014 size Plugin: ODDB::SwissmedicPlugin Error: NoMethodError Message: undefined method `at' for #<RubyXL::Row:0x0000001aee03f8> Backtrace: /var/www/oddb.org/src/plugin/swissmedic.rb:442:in `block in source_row'

  1. ]

Fixed this error, too. Reloading db and restarting import_daily too. After a successfull import of the fachinfo my cablecom had a network error (around 19:04) and I had to restart the import_daily again. Now I received the emails from FI and PI. Update BSV still running. Pushing Update to use swissmedic-diff 0.1.8 to fix to_i-error.

I see (again) several errors like this

NoMethodError: undefined method `fachinfo' for nil:NilClass when updating index 'interactions_index_de' with a ODDB::Sequence
["(eval):2:in `block in proc_instance_origin'", "/usr/local/lib/ruby/gems/1.9.1/gems/odba-1.1.0/lib/odba/index.rb:202:in `call'", "/usr/local/lib/ruby/gems/1.9.1/gems/odba-1.1.0/lib/odba/index.rb:202:in `update_target'", "/usr/local/lib/ruby/gems/1.9.1/gems/odba-1.1.0/lib/odba/index.rb:161:in `update'"]
[...]

After running emerge --umerge ruby I was unable to emerge ruby18!!

Fix print button in Rezeptansicht. Add it to the watir tests

Zeno remarked that the print button in Rezeptansicht did not work in oddb.org

view · edit · sidebar · attach · print · history
Page last modified on July 07, 2014, at 09:20 PM