view · edit · sidebar · attach · print · history

Index>

20140902-fix-daily-job

Summary

  • Fix problems with import daily Error: SL-Update (XML)
  • Add import new migel-XLS file to import_daily

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 Error Export: Mail Download-Invoices

Error: TypeError
Message: can't iterate from Time
Backtrace:
/var/www/oddb.org/src/plugin/download_invoicer.rb:37:in `each'
/var/www/oddb.org/src/plugin/download_invoicer.rb:37:in `include?'
/var/www/oddb.org/src/plugin/download_invoicer.rb:37:in `include?'
/var/www/oddb.org/src/plugin/download_invoicer.rb:37:in `block (2 levels) in filter_paid'
/var/www/oddb.org/src/plugin/download_invoicer.rb:36:in `each_value'
/var/www/oddb.org/src/plugin/download_invoicer.rb:36:in `block in filter_paid'
/var/www/oddb.org/src/plugin/download_invoicer.rb:35:in `each_value'
/var/www/oddb.org/src/plugin/download_invoicer.rb:35:in `filter_paid'
/var/www/oddb.org/src/plugin/download_invoicer.rb:13:in `run'
/var/www/oddb.org/src/util/exporter.rb:331:in `block in mail_download_invoices'
/var/www/oddb.org/src/util/exporter.rb:431:in `call'
/var/www/oddb.org/src/util/exporter.rb:431:in `safe_export'
/var/www/oddb.org/src/util/exporter.rb:330:in `mail_download_invoices'
/var/www/oddb.org/src/util/exporter.rb:59:in `block in run'
/var/www/oddb.org/src/util/schedule.rb:10:in `call'
/var/www/oddb.org/src/util/schedule.rb:10:in `run_on_monthday'
/var/www/oddb.org/src/util/exporter.rb:58:in `run'
jobs/export_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/export_daily:12:in `<module:Util>'
jobs/export_daily:11:in `<module:ODDB>'
jobs/export_daily:10:in `<main>'

Tests under test/test_plugin/download_invoicer.rb run fine and do not produce an error. Same for test/test_util/updater.rb and test/test_util/exporter.rb.

Patching src/util/exporter.rb to run only mail_download_invoices. Starting export_daily to try to reproduce the problem locally. Cannot reproduce it locally as I probable do not have any invoices. Therefore looking at the code to see whether I have a good idea on howto fix this problem without breaking anything.

Patched src/util/exporter to run only mail_download_invoices and the error appears after a few seconds. This makes finding the error much easier. Now looking at the failing invoice. The following output helps me to track the error

2014-09-02 09:02:13 +0200: safe_export Mail Download-Invoices starting
2014-09-02 09:02:13 +0200: run for 1 items
2014-09-02 09:02:13 +0200: filter_paid for [#<ODBA::Stub:96099980#32223603 @odba_class=ODDB::InvoiceItem @odba_container=96898080#800271>]
2014-09-02 09:02:14 +0200: filter_paid invoice 11305217 Hash
<..>
2014-09-02 09:02:14 +0200: filter_paid invoice 1492505 Hash
/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 Export: Mail Download-Invoices - 09/2014 size Error: TypeError
Message: can't iterate from Time
Backtrace:
/var/www/oddb.org/src/plugin/download_invoicer.rb:49:in `each'
/var/www/oddb.org/src/plugin/download_invoicer.rb:49:in `include?'
/var/www/oddb.org/src/plugin/download_invoicer.rb:49:in `include?'
/var/www/oddb.org/src/plugin/download_invoicer.rb:49:in `block (2 levels) in filter_paid'
<..>

Using bin/admin.

# bad value
ch.oddb> invoice('1492505').items.first.class
-> Array
ch.oddb> invoice('1492505').items.first[0].class
-> Fixnum
ch.oddb> invoice('1492505').items.first[1].class
-> ODDB::InvoiceItem

Okay, I was chasing the wrong path. Also calling DownloadInvoicer.new(self).run in bin/admin return can't iterate from Time.

This irb-snippets shows, that Range.include? does not work for Time, but Range.cover? does.

irb(main):001:0> now = Time.now
=> 2014-09-02 10:33:24 +0200
irb(main):002:0> range=now..now
=> 2014-09-02 10:33:24 +0200..2014-09-02 10:33:24 +0200
irb(main):003:0> range.include?(Time.now)
TypeError: can't iterate from Time
        from (irb):3:in `each'
        from (irb):3:in `include?'
        from (irb):3:in `include?'
        from (irb):3
        from /home/niklaus/.rbenv/versions/1.9.3-p0/bin/irb:12:in `<main>'
irb(main):004:0> range.cover?(Time.now)
=> false
irb(main):005:0> range.cover?(now)
=> true

And in http://dev.ywesee.com/Choddb/Ruby193p0 you see that Masa changed a few occurences of range.include? -> range.cover?. But why the hell did this code ever run in the last months?

But why did the unit tests not show this bug? Discovered that with commit c3355b800b82229d004568640c9bee0c443e217c (May 2012) the unittests converted the Time-entities to String to make the test pass. Reverted these changes and now the unittests running against the the unmodified code throw as expected the following exceptions

  1) Error:
ODDB::TestDownloadInvoicer#test_filter_paid__empty:
TypeError: can't iterate from Time
    /opt/src/oddb.org/src/plugin/download_invoicer.rb:37:in `each'
    /opt/src/oddb.org/src/plugin/download_invoicer.rb:37:in `include?'
    /opt/src/oddb.org/src/plugin/download_invoicer.rb:37:in `include?'
    /opt/src/oddb.org/src/plugin/download_invoicer.rb:37:in `block (2 levels) in filter_paid'
    /opt/src/oddb.org/src/plugin/download_invoicer.rb:36:in `each_value'
    /opt/src/oddb.org/src/plugin/download_invoicer.rb:36:in `block in filter_paid'
    /opt/src/oddb.org/src/plugin/download_invoicer.rb:35:in `each_value'
    /opt/src/oddb.org/src/plugin/download_invoicer.rb:35:in `filter_paid'
    test/test_plugin/download_invoicer.rb:94:in `test_filter_paid__empty'

Corrected the unit-tests and now they pass only wiht my change. Now I am satisfied and pushed the commit Fix Maildownload-Invoicer

Add import new migel-XLS file to import_daily

Zeno will publish the Migel-XLS file on github https://github.com/zdavatz/oddb2xml_files/blob/master/MiGeL.xls where we must download it and if newer than the last one. To import it might be probably the easiest was to transform each of the three tables to a CSV and then use the Migel updater as described under http://dev.ywesee.com/Choddb/MiGel. We willl use data/migel to store the files.

Problem ist that Updater.new(self).update_migel does not work at all under bin/admin. Must make the spec tests pass, as already in the todo list since last June. Merged changes from my branch unittests and made the tests pass under Ruby 1.9.3 with commit

Calling MIGEL_SERVER.update_migelid_date under bin/admin produces No such file or directory - migelcode_date.dat. Therefore we want change ist something like MIGEL_SERVER.update_migel. But we have to consider the fact that the migel is a separate DRB process.

Now working with the migel gem to change it to use the XLS to generate the three language specific CVS file. Working with irb to test and remarked that opening the 587KB big file MiGeL.xls book = Spreadsheet.open 'data/csv/MiGeL.xls takes a long time and consumes a lot of memory. Looks like it is going into an eternal loop as after 5 minutes it consumed 8 GB. Killing it. Seems like we found a bug in -spreadsheet-. No bug lies in irb, as the same command finishes quickly when running via a real ruby script.

Tests are now able to download the xls and create the three *.csv files.

view · edit · sidebar · attach · print · history
Page last modified on September 02, 2014, at 04:22 PM