view · edit · sidebar · attach · print · history

20111020-mymigel-lookandfeel-encoding-ruby193-update-export_fachinfos-oddb_org

<< | Index | >>


  1. Check kindle ebook
  2. Create a new lookandfeel for mymigel
  3. Debug DDD ruby193 oddb.org
  4. Data missing problem ruby193 oddb.org suspend
  5. Insert package size in 'Preisvergleich' section of ebook

Goal/Estimate/Evaluation
  • migel lookandfeel oddb.org / 90% / 100%
  • ddd ruby193 oddb.org / 80% / 100%
  • migrate_to_utf8 ruby193 / 90% / 80%
Milestones
  1. Check kindle ebook
  2. Check galenic form data oddb.org
  3. mymigel look&feel
  4. update ddd link
  5. check migrate script
  6. check importer
  7. check exporter

Commit


Check kindle ebook

Access

Create a new lookandfeel for mymigel

Setting log

Procedure

  1. DNS (locally added a new hostname in /etc/hosts)
  2. Virtual Host (/etc/apache2/vhost.d/)
  3. Webalizer
  4. Look&Feel

Updates

  • src/custom/lookandfeelfactory.rb
 module ODDB
   class LookandfeelFactory < SBSM::LookandfeelFactory
   ...
     'mymigel'=> [
       LookandfeelMyMigel,
     ],
  • src/custom/lookandfeelwrapper.rb (define LookandfeelMyMigel class)
  class LookandfeelMyMigel < SBSM::LookandfeelWrapper
  ...
  • /etc/apache2/vhost.d/09_mymigel_vhost.conf

Attach:09_mymigel_vhost.conf.20111020.txt

Restart

 sudo /etc/init.d/apache2 restart

Run

 bin/oddbd
 webalizer -c /etc/webalizer/mymigel.oddb.org.conf

Note

  • on the server, webalizer is called from /usr/local/bin/update_vhots_stat scheduled by /etc/crontab each 10 minutes
  • /etc/crontab
 # update webalizer stats for virtual hosts
 */10  *  * * *  root /usr/local/bin/update_vhost_stats
  • /usr/local/bin/update_vhost_stats
#!/bin/bash

for conf in /etc/webalizer/*.conf
do
        webalizer -c $conf &> /dev/null
done

Check (locally)

Check (online)

Note

  • webalizer analyze access log
  • Access log is outputted by cronolog
  • cronnolog is called from apache and the setting is written in the virtual host conf file

Process

  1. User access
  2. apache calls cronolog
  3. cronolog outputs access log
  4. crond calls webalizer
  5. webalizer analyze access log and output data
  6. the url address is allowed by vhost and DNS (/etc/hosts) setting

Commit

Debug DDD ruby193 oddb.org

Access to DDD info (for example)

Note

  • This is related to rockit because the pointer address will be parsed by rockit

Solution

  1. resolve rockit
  2. replace the pointer address to the other format one

Updates

  • src/state/drugs/ddd.rb
 def init
   if((pointer = @session.user_input(:pointer)))
     @model = pointer.resolve(@session.app)
   elsif atc_code = @session.user_input(:atc_code) and atc_class = @session.app.atc_class(atc_code)
     @model = atc_class
   else
     @model = nil
   end
  • src/util/validator.rb
    STRINGS = [
      :atc_code,

Run

  • bin/oddbd

Access

Result

  • works

Updates

  • src/view/drugs/atcchooser.rb
 module AtcDddLink
   def atc_ddd_link(atc, session=@session)
     if(atc && atc.has_ddd?)
       link = HtmlGrid::Link.new(:ddd, atc, session, self)
       link.href = @lookandfeel._event_url(:ddd, {'atc_code'=>atc.code})

Access

Result

  • URL has changed

Commit

Data missing problem ruby193 oddb.org

Problem

  • oddbd on Ruby 1.9.3 runs after migrate_to_utf8
  • But once restoring the data by using pg_dump and psql commands, some data is gone
  • The reason is probably because all the data is not saved in the database after the migrate_to_utf8 script runs

Note

  • It seems that Ruby 1.8 cannot load encoded String by Ruby 1.9.3 and Ruby 1.8 deletes the string data because of probably the incompatibility of marshal data

Command log

$ pg_dump -U postgres oddb.org > oddb.org_database.bak.20111020.sql 
$ sudo -u postgres dropdb oddb.org
$ sudo -u postgres createdb -E UTF8 -T template0 oddb.org
$ cat oddb.org_database.bak.20111020.sql | psql -U postgres oddb.org

Run

 ruby193 -I ../oddb/lib bin/oddbd

Access

Error

/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:78: warning: Hash#index is deprecated; use Hash#key
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:78: warning: Hash#index is deprecated; use Hash#key
error in SBSM::Session#to_html: /
NoMethodError
undefined method `[]' for nil:NilClass
/home/masa/ywesee/oddb.org.ruby193/src/model/sponsor.rb:24:in `logo_filename'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/stub.rb:118:in `method_missing'
/home/masa/ywesee/oddb.org.ruby193/src/view/sponsorlogo.rb:22:in `init'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/component.rb:138:in `initialize'
/home/masa/ywesee/oddb.org.ruby193/src/view/logohead.rb:27:in `new'
/home/masa/ywesee/oddb.org.ruby193/src/view/logohead.rb:27:in `sponsor'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:66:in `create'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:301:in `compose_component'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:209:in `block in compose'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:203:in `each'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:203:in `compose'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:55:in `init'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/component.rb:138:in `initialize'
/home/masa/ywesee/oddb.org.ruby193/src/view/custom/head.rb:68:in `new'
/home/masa/ywesee/oddb.org.ruby193/src/view/custom/head.rb:68:in `head'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:66:in `create'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:301:in `compose_component'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:209:in `block in compose'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:203:in `each'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:203:in `compose'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:55:in `init'
/home/masa/ywesee/oddb.org.ruby193/src/view/publictemplate.rb:51:in `init'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/component.rb:138:in `initialize'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/sbsm-1.0.0/lib/sbsm/state.rb:243:in `new'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/sbsm-1.0.0/lib/sbsm/state.rb:243:in `view'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/sbsm-1.0.0/lib/sbsm/state.rb:179:in `to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/sbsm-1.0.0/lib/sbsm/session.rb:450:in `to_html'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/sbsm-1.0.0/lib/sbsm/session.rb:170:in `block in drb_process'
<internal:prelude>:10:in `synchronize'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/sbsm-1.0.0/lib/sbsm/session.rb:168:in `drb_process'
/home/masa/bin/ruby193rc1/lib/ruby/1.9.1/drb/drb.rb:1548:in `perform_without_block'
/home/masa/bin/ruby193rc1/lib/ruby/1.9.1/drb/drb.rb:1508:in `perform'
/home/masa/bin/ruby193rc1/lib/ruby/1.9.1/drb/drb.rb:1586:in `block (2 levels) in main_loop'
/home/masa/bin/ruby193rc1/lib/ruby/1.9.1/drb/drb.rb:1582:in `loop'
/home/masa/bin/ruby193rc1/lib/ruby/1.9.1/drb/drb.rb:1582:in `block in main_loop'
ODDB::View::WelcomeHead::COMPONENTS[[1, 0, 0]] in create(sponsor)
ODDB::View::Drugs::Search::COMPONENTS[[0, 0]] in create(head)
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:78: warning: Hash#index is deprecated; use Hash#key
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/composite.rb:78: warning: Hash#index is deprecated; use Hash#key
error in SBSM::Session#http_headers: /
NoMethodError
undefined method `[]' for nil:NilClass
/home/masa/ywesee/oddb.org.ruby193/src/model/sponsor.rb:24:in `logo_filename'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/stub.rb:118:in `method_missing'
/home/masa/ywesee/oddb.org.ruby193/src/view/sponsorlogo.rb:22:in `init'
/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.0/lib/htmlgrid/component.rb:138:in `initialize'
/home/masa/ywesee/oddb.org.ruby193/src/view/logohead.rb:27:in `new'

Next

  • Check the saving part of migrate_to_utf8

Note

  • There are 4 kinds of error during migrate_to_utf8 script
    1. ODDB::Stub error
    2. Encoding::CompatibilityError in a regular expression related to an index table
    3. TypeError
    4. NoMethod Error

Example

  • ODDB::Stub error
 ODBA::Stub was unable to replace Hash#27584864 from ODDB::Sequence:#70501
  • Encoding::CompatibilityError in a regular expression related to an index table
 Encoding::CompatibilityError: incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) when updating index 'atc_index_company' with a ODDB::AtcClass
 ["/home/masa/ywesee/oddb.org.ruby193/src/model/company.rb:163:in `split'", "/home/masa/ywesee/oddb.org.ruby193/src/model/company.rb:163:in `search_terms'", "/home/masa/bin/ruby193rc1/lib/ruby
 /gems/1.9.1/gems/odba-1.0.0/lib/odba/stub.rb:118:in `method_missing'", "(eval):3:in `block in proc_resolve_search_term'"]
  • TypeError
 TypeError: can't convert String into Integer when updating index 'sequence_generic_type_index' with a ODDB::Sequence
 ["/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/index.rb:301:in `[]'", "/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/index.rb:301:in `block in 
 current_ids'", "/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/index.rb:299:in `collect'", "/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib
 /odba/index.rb:299:in `current_ids'"]
  • NoMethod Error
 NoMethodError: undefined method `inject' for nil:NilClass when updating index 'atc_index_company' with a ODDB::Company
 ["/home/masa/ywesee/oddb.org.ruby193/src/model/company.rb:48:in `atc_classes'", "(eval):2:in `block in proc_instance_target'", "/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib
 /odba/index.rb:249:in `call'", "/home/masa/bin/ruby193rc1/lib/ruby/gems/1.9.1/gems/odba-1.0.0/lib/odba/index.rb:249:in `update_origin'"]

Insert package size in 'Preisvergleich' section of ebook

Note

  • A decorator should be updated in order to put some more string in the Preisvergleigh section.

Problem

  • fachinfo.yaml does not include package size information

Solution

  • Update export_fachinfos method in oddb.org to include package size information

Update

  • src/model/registration_observer.rb
 module ODDB
   module RegistrationObserver
 ...
    def article_codes
      codes = []
      @registrations.collect { |reg|
        reg.each_package { |pac|
          cds = {
            :article_ean13 => pac.barcode.to_s,
          }
          if(pcode = pac.pharmacode)
            cds.store(:article_pcode, pcode)
          end
          if(psize = pac.size)
            cds.store(:article_size, psize)
          end
          codes.push(cds)
        }
      }
      codes
    end

Run

bin/oddbd
ext/export/bin/exportd

bin/admin

 ch.oddb> ODDB::YamlExporter.new(self).export_fachinfos

Result

view · edit · sidebar · attach · print · history
Page last modified on October 21, 2011, at 07:14 AM