view · edit · sidebar · attach · print · history

Index>

20170522-vetoquinol-rack

Summary

  • Port vetoquinol to use the rack based SBSM
  • Fix errors in virbac.bbmb.ch
  • Keep in Mind

Commits

Index

Port vetoquinol to use the rack based SBSM

In order to allow an easy debugging of the old and new version I will

  • start a new branch rack
  • create a tag before_rack on the current HEAD
  • create a service vetoquinol_rack
  • use /var/www/vetoquinol_rack.bbmb.ch/ as the installation dictionary
  • use vetoquinol_rack.ngiger.ch as host_name for the apache configuration

Next modification are:

  • Require BBMB >= 2.2.2 in Gemfile. Calling bundle install to verify that it works
  • Create a config.ru (Copied from virbac, using port 8009, small modifications)
  • As there is no bin/admin file, I will (at least at this moment) not create one neither
  • Now bundle exec test/util/test_csv_importer.rb works fine. Same for bundle exec test/util/test_mail.rb.
  • sudo -u bbmb bundle-240 install --path vendor
  • Making sudo -u bbmb bundle-240 exec rackup work.
  • Now visiting http://vetoquinol_rack.ngiger.ch/ presents the same home screen like
  • Fix errors in virbac.bbmb.ch

The following errors exists:

  • Login with ruest gives error undefined method `calculate_effective_prices' for nil:NilClass
  • Creating an order gives undefined method `async' for #<VIRBAC::App:0x005647fc671b88>

These errors must be fixed.

Breaking into pry at lib/bbmb/html/state/current_order.rb:21, gives me

[1] pry(#<BBMB::Html::State::CurrentOrder>)> @model.class
=> SBSM::UnknownUser
# Relevant backtrace is
/home/niklaus/git/bbmb/lib/bbmb/html/state/current_order.rb:21:in `init'
/home/niklaus/git/sbsm/lib/sbsm/session.rb:223:in `block in process_rack'
/home/niklaus/git/sbsm/lib/sbsm/session.rb:207:in `synchronize'
/home/niklaus/git/sbsm/lib/sbsm/session.rb:207:in `process_rack'
/home/niklaus/git/sbsm/lib/sbsm/app.rb:119:in `call'

Wondering Why I have an SBSM::UnknownUser after a successful login. In log/2017/05/22/app_log I find

172.25.1.75 - - [22/May/2017:09:00:52 +0200] "GET /resources/bbmb/bbmb.css HTTP/1.1" 200 4795 0.0012
D, [2017-05-22T09:00:57.502868 #30597] DEBUG -- : app.rb:118:in `call' starting session_id 15e98c7b8ec852362292a605138  session BBMB::Html::Util::Session /de/bbmb: cookies  are {"_session_id"=>"15e98c7b8ec852362292a605138", "language"=>"de"} @cgi NilClass
I, [2017-05-22T09:00:57.504739 #30597]  INFO -- : login.rb:19:in `login' BBMB::Html::State Login login ruth.ruesch@bluewin.ch a3232dfbd92ab0d756c168a064426893  NilClass
I, [2017-05-22T09:00:57.528064 #30597]  INFO -- : session.rb:35:in `login' BBMB::Html::Util::Session login ruth.ruesch@bluewin.ch a3232dfbd92ab0d756c168a064426893  BBMB::Html::Util::KnownUser BBMB.auth #<Yus::Server:0x00000002744eb8> auth_session #<Yus::EntitySession:0x00000002638f88>
I, [2017-05-22T09:00:57.528913 #30597]  INFO -- : global.rb:26:in `initialize' BBMB::Html::State Global session BBMB::Html::Util::Session model SBSM::UnknownUser
D, [2017-05-22T09:00:57.529026 #30597] DEBUG -- : session.rb:217:in `block in process_rack' active_state.trigger state 70057367282580 BBMB::Html::State::CurrentOrder remember nil

Comparing this log with a successfull login gives

D, [2017-05-22T09:09:18.952812 #30597] DEBUG -- : app.rb:118:in `call' starting session_id 15e98c7b8ec852362292a605138  session BBMB::Html::Util::Session /de/bbmb: cookies  are {"_session_id"=>"15e98c7b8ec852362292a605138", "language"=>"de"} @cgi NilClass
I, [2017-05-22T09:09:18.954784 #30597]  INFO -- : login.rb:19:in `login' BBMB::Html::State Login login claude.meier@gmx.net d93591bdf7860e1e4ee2fca799911215  NilClass
I, [2017-05-22T09:09:18.984057 #30597]  INFO -- : session.rb:35:in `login' BBMB::Html::Util::Session login claude.meier@gmx.net d93591bdf7860e1e4ee2fca799911215  BBMB::Html::Util::KnownUser BBMB.auth #<Yus::Server:0x00000002744eb8> auth_session #<Yus::EntitySession:0x00000002a219b0>
I, [2017-05-22T09:09:18.986687 #30597]  INFO -- : global.rb:26:in `initialize' BBMB::Html::State Global session BBMB::Html::Util::Session model SBSM::UnknownUser
D, [2017-05-22T09:09:18.986822 #30597] DEBUG -- : session.rb:217:in `block in process_rack' active_state.trigger state 70057365486140 BBMB::Html::State::CurrentOrder remember nil

pry show
[1] pry(#<BBMB::Html::State::CurrentOrder>)> @model
=> #<SBSM::UnknownUser:0x0055bbdbbbd018>
# Relevant backtrace is
/home/niklaus/git/bbmb/lib/bbmb/html/state/current_order.rb:21:in `init'
/home/niklaus/git/sbsm/lib/sbsm/session.rb:223:in `block in process_rack'
/home/niklaus/git/sbsm/lib/sbsm/session.rb:207:in `synchronize'
/home/niklaus/git/sbsm/lib/sbsm/session.rb:207:in `process_rack'
/home/niklaus/git/sbsm/lib/sbsm/app.rb:119:in `call'

The backtrace is the same for both cases. Looking in detail at the method _customer in , shows that in the unsuccessfull case I get an error :ODBA::Stub was unable to replace #269599 from BBMB::Model::Customer:#2617. Therefore I must find again a workaround for a database inconsistency. Created private helper method delete_invalid_positions.

Also see:

But maybe the problem is rooted in the async method (where we use a Mutex) not working correctly when submitting an order. Pushed commits

The workaound for the undefined method `calculate_effective_prices' for nil:NilClass, took a little bit time as the method current_order is present in lib/bbmb/persistence/odba/model/customer.rb and lib/bbmb/model/customer.rb. The easiest was got fix it was adding the line @model = BBMB::Model::Order.new(_customer) if @model.is_a?(NilClass) in the init method of https://github.com/ngiger/bbmb/blob/master/lib/bbmb/html/state/current_order.rb#L21.

This workaroung does not prevent that placing an order raises again an error

NoMethodError: undefined method `quantity' for nil:NilClass
        /var/www/virbac_rack.bbmb.ch/vendor/bundle/ruby/2.4.0/gems/odba-1.1.2/lib/odba/stub.rb:112:in `method_missing'
        /home/niklaus/git/bbmb/lib/bbmb/html/state/result.rb:24:in `ordered_quantity'
        /home/niklaus/git/bbmb/lib/bbmb/html/view/result.rb:75:in `quantity'

Must find a work-around in lib/bbmb/persistence/odba/model/customer.rb, as this method is used in both cases. Found a workaroun there. Afterwards it was possible to place an order, but visiting the Archive aka /de/bbmb/orders/ we got another error

ODBA::Stub was unable to replace BBMB::Model::Order::Position#269595 from Array:#269468
/var/www/virbac_rack.bbmb.ch/vendor/bundle/ruby/2.4.0/gems/htmlgrid-1.1.4/lib/htmlgrid/composite.rb:157: warning: Hash#index is deprecated; use Hash#key
NoMethodError: undefined method `quantity' for nil:NilClass
        /var/www/virbac_rack.bbmb.ch/vendor/bundle/ruby/2.4.0/gems/odba-1.1.2/lib/odba/stub.rb:112:in `method_missing'
        /home/niklaus/git/bbmb/lib/bbmb/model/order.rb:124:in `block in item_count'
        /home/niklaus/git/bbmb/lib/bbmb/model/order.rb:124:in `each'
        /home/niklaus/git/bbmb/lib/bbmb/model/order.rb:124:in `inject'
        /home/niklaus/git/bbmb/lib/bbmb/model/order.rb:124:in `item_count'
        (eval):2:in `send'
        /var/www/virbac_rack.bbmb.ch/vendor/bundle/ruby/2.4.0/gems/htmlgrid-1.1.4/lib/htmlgrid/value.rb:33:in `init'

Added another call to in the method total. Now I can display all the old orders and I see an order of 26.04.2017 11:22 which has no positions. In the app.log I see entries like

, [2017-05-22T11:10:58.623320 #6479]  INFO -- : order.rb:262:in `rescue in block in delete_invalid_positions' Deleting an invalid position from order 708427-162
I, [2017-05-22T11:10:58.623806 #6479]  INFO -- : order.rb:262:in `rescue in block in delete_invalid_positions' Deleting an invalid position from order 708427-162
I, [2017-05-22T11:10:58.624363 #6479]  INFO -- : order.rb:262:in `rescue in block in delete_invalid_positions' Deleting an invalid position from order 708427-162
I, [2017-05-22T11:10:58.624817 #6479]  INFO -- : order.rb:262:in `rescue in block in delete_invalid_positions' Deleting an invalid position from order 708427-162

Did see under de/bbmb/favorites/ 3 empty items. Wen click on "Zu Best. hinzufügen" I get

NoMethodError: undefined method `each' for "1":String
        /home/niklaus/git/bbmb/lib/bbmb/html/state/global.rb:63:in `user_input'
        /home/niklaus/git/bbmb/lib/bbmb/html/state/viral/customer.rb:29:in `_increment_order'
        /home/niklaus/git/bbmb/lib/bbmb/html/state/viral/customer.rb:98:in `increment_order'
        /var/www/virbac_rack.bbmb.ch/vendor/ruby/2.4.0/gems/sbsm-1.4.1/lib/sbsm/state.rb:197:in `_trigger'
        /var/www/virbac_rack.bbmb.ch/vendor/ruby/2.4.0/gems/sbsm-1.4.1/lib/sbsm/state.rb:186:in `trigger'
        /home/niklaus/git/bbmb/lib/bbmb/html/state/global.rb:58:in `trigger'
        /var/www/virbac_rack.bbmb.ch/vendor/ruby/2.4.0/gems/sbsm-1.4.1/lib/sbsm/viralstate.rb:38:in `trigger'
        /var/www/virbac_rack.bbmb.ch/vendor/ruby/2.4.0/gems/sbsm-1.4.1/lib/sbsm/session.rb:217:in `block in process_rack'
        /var/www/virbac_rack.bbmb.ch/vendor/ruby/2.4.0/gems/sbsm-1.4.1/lib/sbsm/session.rb:208:in `synchronize'
        /var/www/virbac_rack.bbmb.ch/vendor/ruby/2.4.0/gems/sbsm-1.4.1/lib/sbsm/session.rb:208:in `process_rack'
        /var/www/virbac_rack.bbmb.ch/vendor/ruby/2.4.0/gems/sbsm-1.4.1/lib/sbsm/app.rb:119:in `call'

But first pushed commits for solved problems:

Fixed the problem deleting an empty favorite with the commit Delete in Schnellbestellung all positions with an invalid product. Verified that deleting a newly added item works.

Pushed commits:

Loading database from fastpower and running some manual tests. The following manual test completed successfully

  • Log in as ruth.ruesch
    • Display its archive (empty order of 26.04.2017)
    • Schnellbestellung displays zero items
    • logout
    • login agaim
    • Add HPM adult dog L+M 3kg to favorites
    • Submit order
    • Show archive with new order
    • logout
    • login againg
    • Show archive with new order
    • Favorites contains previously added item HPM adult dog L+M 3kg
    • logout
  • Log in as windwasser
    • Schnellbestellung displys 1 item
    • Bestellung auslösen worked
    • Display its archive with a new order as of tody
    • logout
  • Login as claude.meier
    • Display archive
    • Favorites display 0 item
    • Adding HPM adult cat 1,5kg to favorites and order
    • Submitting order
    • Display archive (contains new order)
    • logout
    • login againg
    • Display archive (contains new order)
    • Schnellbestellung displys the newly added item HPM adult cat 1,5kg

Verified that /var/www/virbac_rack.bbmb.ch/log/2017/05/22/app_log contains a line containing Used version: sbsm 1.4.1, bbmb 2.2.3 virbac b5858645ead85005e5f02d20d25db29b95570b88

We still have an error when we enter some text into Interne Bestellnummer and Bemerkungen which result in output of {"reference":"Interne Bestellnummer 00555","comment":"Bemerkung","priority":"","total":"47.70"}. In th app.log I find

D, [2017-05-22T12:56:00.573806 #28801] DEBUG -- : app.rb:118:in `call' starting session_id 15e98c7b8ec852362292a605138  session BBMB::Html::Util::Session /de/bbmb: cookies  are {"_session_id"=>"15e98c7b8ec852362292a605138", "factor"=>"2", "language"=>"de"} @cgi NilClass
D, [2017-05-22T12:56:00.597659 #28801] DEBUG -- : session.rb:218:in `block in process_rack' active_state.trigger state 47181389708500 BBMB::Html::State::Json remember nil
D, [2017-05-22T12:56:00.597748 #28801] DEBUG -- : session.rb:231:in `block in process_rack' Stay in volatile state 47181389708500 BBMB::Html::State::Json
D, [2017-05-22T12:56:00.597928 #28801] DEBUG -- : app.rb:137:in `call' finish session_id.2 15e98c7b8ec852362292a605138: headers {"Content-Length"=>"95", "Content-Type"=>"text/javascript; charset=UTF-8"}
172.25.1.75 - - [22/May/2017:12:56:00 +0200] "POST /de/bbmb HTTP/1.1" 200 95 0.0246

The class BBMB::Html::State::Json defines the constant VOLATILE as true. Therefore I think it is related to the problem we have displaying the password as these are the only two occurences of VOLATILE in bbmb. Placing a puts into lib/bbmb/html/view/json.rb to track the output of to_html without and with remarks.

Commited an order for windwasser and found the following output in the console

/var/www/virbac_rack.bbmb.ch/vendor/ruby/2.4.0/gems/odba-1.1.2/lib/odba/marshal.rb:10: warning: #<BBMB::Model::Order::Position:0x007f07c4435080>.respond_to?(:marshal_dump) uses the deprecated method signature, which takes one parameter
/home/niklaus/git/bbmb/lib/bbmb/model/order.rb:48: warning: respond_to? is defined here
/var/www/virbac_rack.bbmb.ch/vendor/ruby/2.4.0/gems/odba-1.1.2/lib/odba/marshal.rb:10: warning: #<BBMB::Model::Order::Position:0x007f07c4435080>.respond_to?(:_dump) uses the deprecated method signature, which takes one parameter
/home/niklaus/git/bbmb/lib/bbmb/model/order.rb:48: warning: respond_to? is defined here
undefined method `send_order' for #<VIRBAC::App:0x0055b2a44a3880>
/home/niklaus/git/sbsm/lib/sbsm/session.rb:140:in `method_missing'
/home/niklaus/git/bbmb/lib/bbmb/html/state/current_order.rb:48:in `block in commit'

Re-Added the method send_order order, customer in lib/bbmb/util/app.rb. Now I have the following backtrace when entering an order without comments

 "/home/niklaus/git/bbmb/lib/bbmb/util/app.rb:67:in `send_order'",
 "/home/niklaus/git/bbmb/lib/bbmb/html/state/current_order.rb:49:in `block in commit'"]

Calling continue after in send_order shows for a few seconds Ihre Bestellung wurde an Virbac verschickt and then we are back in de/bbmb/current_order/

The hash we see when sending the command fails is generated in the method ajax of BBMB::Html::State::CurrentOrder. After going back and reloading the page it is possible to commit the order. In this case the Rack-Requests contains

[1] pry(#<BBMB::Html::Util::Session>)> rack_request.env['rack.request.form_vars']
=> "reference=test22&comment=Test+23&commit=Bestellung+ausl%C3%B6sen&flavor=bbmb&language=de&event=commit&state_id=47038836051820"

In the failing case we have

"reference=Test1&comment=Test2&commit=Bestellung+ausl%C3%B6sen&flavor=bbmb&language=de&event=ajax&state_id=70244125881260",
 "rack.request.form_input"=>#<Rack::Lint::InputWrapper:0x007fc5f8a84358 @input=#<Rack::Lint::InputWrapper:0x007fc5f8a87030 @input=#<StringIO:0x007fc5f8a8de30>

Looked at the JavaScript console and found the following error when adding a comment

order.js:46 Uncaught TypeError: Cannot read property 'bind' of undefined
    at update_order (order.js:46)
    at HTMLInputElement.onchange (bbmb:10)

After prepending require(["dojo/domReady!"], before each function in doc/resources/javascript/order.js, I have another javascript error and the script gets reloaded continuosly. The error is dojo.js:8 TypeError: Cannot read property 'event' of undefined at update_order (order.js:43)

Pushed commits for BBMB:

If I comment out the line self.onload = 'window.opener.location.reload();' in lib/bbmb/html/view/show_pass.rb, the generated password is display correctly. However when you close the pop-up window and press again on Passwort anzeigen there is no password displayed at all. Going back and generating a new password helps however.

Pushed commits

view · edit · sidebar · attach · print · history
Page last modified on May 22, 2017, at 05:20 PM