As we have now a working bin/virbac_admin we want to solve the question why some virbac customer cannot login (unless one does set them a new password via the web as admin user). Example is customer 702329
ch.bbmb.virbac> BBMB::Model::Customer.find_by_customer_id('702329').address_lines -> ["Balcer", "", "& Colette Berner", "Weidstrasse 7", "8580 Amriswil"] ch.bbmb.virbac> BBMB::Model::Customer.find_by_customer_id('702329').orders.last -> #<BBMB::Model::Order:0x007f45c69c2698> ch.bbmb.virbac> $customer.orders.size -> 1 ch.bbmb.virbac> $customer.orders.last.commit_time -> 2017-06-06 10:40:56 +0200 ch.bbmb.virbac> $customer.orders.last.customer.customer_id -> 702329 ch.bbmb.virbac> $orders = ODBA.cache.extent(BBMB::Model::Order).find_all {|c| c.customer && c.customer.customer_id.eql?('702329')} ch.bbmb.virbac> $orders = ODBA.cache.extent(BBMB::Model::Order).find_all {|c| c.customer && c.customer.customer_id.eql?('702329')} -> Array ch.bbmb.virbac> $orders.size -> 3 ch.bbmb.virbac> $orders.first.commit_time -> ch.bbmb.virbac> $orders[1].commit_time -> 2017-06-06 10:40:56 +0200 ch.bbmb.virbac> $orders.last.commit_time -> ch.bbmb.virbac> $orders.last.commit_id -> ch.bbmb.virbac> $orders = ODBA.cache.extent(BBMB::Model::Order).find_all {|c| c.customer.nil?}.size -> 5751 ch.bbmb.virbac> $orders = ODBA.cache.extent(BBMB::Model::Order).size -> 10400
Conclusion: The database is not consistent as we have 5751 of 10400 which are no longer linked to a customer. Is it possible to extract some info for these orders?
ch.bbmb.virbac> $orders = ODBA.cache.extent(BBMB::Model::Order).find_all {|c| c.customer.nil?}.first.additional_info -> {:comment=>"Das ist eine Testbestellung f\xC3\xBCr Frans Mittermayer.", :priority=>21} ch.bbmb.virbac> $orders = ODBA.cache.extent(BBMB::Model::Order).find_all {|c| c.customer.nil?}.last.additional_info -> {:priority=>1, :reference=>"feligen CRP"} ch.bbmb.virbac> $orders = ODBA.cache.extent(BBMB::Model::Order).find_all {|c| c.customer.nil?}.first.filename -> no_customer-2-20070423114113.txt ch.bbmb.virbac> $orders = ODBA.cache.extent(BBMB::Model::Order).find_all {|c| c.customer.nil?}.last.filename -> undefined method `strftime' for nil:NilClass ch.bbmb.virbac> $orders = ODBA.cache.extent(BBMB::Model::Order).find_all {|c| c.customer.nil?}.first.order_id -> no_customer-2 ch.bbmb.virbac> $orders = ODBA.cache.extent(BBMB::Model::Order).find_all {|c| c.customer.nil?}.last.order_id -> no_customer-
It is possible to find all customers which have no orders attached. These are probably the ones, which cannot log-in anymore.
ch.bbmb.virbac> $customer_no_orders = ODBA.cache.extent(BBMB::Model::Customer).find_all{|c| c.orders.size == 0 } -> Array ch.bbmb.virbac> $customer_no_orders.size -> 1073 ch.bbmb.virbac> $customer_no_orders.first.email -> info@mobti.vet ch.bbmb.virbac> $customer_no_orders.last.email -> info@tierarztpraxis-madiswil.ch
Now we are searching for all customers which have at least one order attached
ch.bbmb.virbac> $customer_with_orders = ODBA.cache.extent(BBMB::Model::Customer).find_all{|c| c.orders.size > 0 } -> Array ch.bbmb.virbac> $customer_with_orders.size -> 76 ch.bbmb.virbac> $customer_with_orders.first.email -> dthiebaud@bluewin.ch ch.bbmb.virbac> $customer_with_orders.last.email -> markus.nydegger@bluewin.ch $info = $customer_no_orders.collect{|c| "#{c.customer_id},#{c.email}"} -> Array SBSM.info $info.join("\n")
Now I find the list of these customers in the file log/2017/06/07/app_log.
Simplyfing reading the bbmb/config by forcing it to read the config.yml in the etc subdirectory. Allow it to be overridden by specifying the config=/path/to/config. This make working with these admin tools as simple as in oddb.org.
Done for sandoz. Checking there the customers and orders too
ch.bbmb.sandoz> $orders = ODBA.cache.extent(BBMB::Model::Order).find_all {|c| c.customer.nil?} -> Array ch.bbmb.sandoz> $orders.size -> 30 ch.bbmb.sandoz> $orders = ODBA.cache.extent(BBMB::Model::Order).find_all {|c| c.customer.nil?}.first.additional_info -> {} ch.bbmb.sandoz> $customer_no_orders = ODBA.cache.extent(BBMB::Model::Customer).find_all{|c| c.orders.size == 0 } -> Array ch.bbmb.sandoz> $customer_no_orders.size -> 1093 ch.bbmb.sandoz> $customer_with_orders = ODBA.cache.extent(BBMB::Model::Customer).find_all{|c| c.orders.size > 0 } -> Array ch.bbmb.sandoz> $customer_with_orders.size -> 586
Sandoz.xmlconv did not have a bin/admin interface till today. Also it does not use BBMB. Therefore I must adapt it a bit more. Must also adapt reading the config files in xmlconv/config to use the current directory. Under mod_ruby we used the DOCUMENT_ROOT. But now the Rack use by default the config.ru from their current working directory.
But specifying the full path works for sandoz.xmlconv. eg. sudo -u bbmb /usr/local/bin/ruby-240 /usr/local/bin/xmlconv_admin config=/var/www/sandoz.xmlconv.bbmb.ch/etc/xmlconv.yml
Pushed commits
Injection fails with
RuntimeError Bestellung OK, Eintrag in BBMB fehlgeschlagen: NoMethodError undefined method `inject_order' for # (druby://localhost:12004) /var/www/sandoz.bbmb.ch/vendor/ruby/2.4.0/gems/bbmb-2.3.0/lib/bbmb/util/server.rb:46:in `inject_order' (druby://localhost:12004) /usr/local/ruby-2.4.0/lib/ruby/2.4.0/drb/drb.rb:1624:in `perform_without_block' (druby://localhost:12004) /usr/local/ruby-2.4.0/lib/ruby/2.4.0/drb/drb.rb:1584:in `perform' (druby://localhost:12004) /usr/local/ruby-2.4.0/lib/ruby/2.4.0/drb/drb.rb:1668:in `block (2 levels) in main_loop' (druby://localhost:12004) /usr/local/ruby-2.4.0/lib/ruby/2.4.0/drb/drb.rb:1664:in `loop' (druby://localhost:12004) /usr/local/ruby-2.4.0/lib/ruby/2.4.0/drb/drb.rb:1664:in `block in main_loop' /var/www/sandoz.xmlconv.bbmb.ch/lib/postprocess/bbmb2.rb:38:in `block in inject' /var/www/sandoz.xmlconv.bbmb.ch/lib/postprocess/bbmb2.rb:16:in `each' /var/www/sandoz.xmlconv.bbmb.ch/lib/postprocess/bbmb2.rb:16:in `each_with_index' /var/www/sandoz.xmlconv.bbmb.ch/lib/postprocess/bbmb2.rb:16:in `inject' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/bundler/gems/xmlconv-22fc7ae96f58/lib/xmlconv/util/transaction.rb:105:in `block in postprocess' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/bundler/gems/xmlconv-22fc7ae96f58/lib/xmlconv/util/transaction.rb:102:in `each' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/bundler/gems/xmlconv-22fc7ae96f58/lib/xmlconv/util/transaction.rb:102:in `postprocess' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/bundler/gems/xmlconv-22fc7ae96f58/lib/xmlconv/util/application.rb:44:in `_execute' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/bundler/gems/xmlconv-22fc7ae96f58/lib/xmlconv/util/application.rb:36:in `execute' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/bundler/gems/xmlconv-22fc7ae96f58/lib/xmlconv/util/application.rb:140:in `execute_with_response' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/bundler/gems/xmlconv-22fc7ae96f58/lib/xmlconv/state/login.rb:28:in `initialize' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/sbsm-1.4.3/lib/sbsm/session.rb:384:in `new' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/sbsm-1.4.3/lib/sbsm/session.rb:384:in `logout' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/sbsm-1.4.3/lib/sbsm/session.rb:224:in `block in process_rack' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/sbsm-1.4.3/lib/sbsm/session.rb:209:in `synchronize' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/sbsm-1.4.3/lib/sbsm/session.rb:209:in `process_rack' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/sbsm-1.4.3/lib/sbsm/app.rb:119:in `call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/lint.rb:49:in `_call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/lint.rb:37:in `call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/show_exceptions.rb:23:in `call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/content_length.rb:15:in `call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/static.rb:149:in `call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/common_logger.rb:33:in `call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/tempfile_reaper.rb:15:in `call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/lint.rb:49:in `_call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/lint.rb:37:in `call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/show_exceptions.rb:23:in `call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/common_logger.rb:33:in `call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/chunked.rb:54:in `call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/content_length.rb:15:in `call' /var/www/sandoz.xmlconv.bbmb.ch/vendor/ruby/2.4.0/gems/rack-2.0.3/lib/rack/handler/webrick.rb:86:in `service' /usr/local/ruby-2.4.0/lib/ruby/2.4.0/webrick/httpserver.rb:140:in `service' /usr/local/ruby-2.4.0/lib/ruby/2.4.0/webrick/httpserver.rb:96:in `run' /usr/local/ruby-2.4.0/lib/ruby/2.4.0/webrick/server.rb:290:in `block in start_thread' hospital: 99
Why does this not fail locally? Looks like the drb_url is wrong in Bbmb2.inject(drb_url, idtype, transaction=nil)