view · edit · sidebar · attach · print · history

Index | Niklaus.20230103-ruby-320-ydim-oekk >>

20240130-ruby-330

Summary

  • Port oddb.org to Ruby 3.3
  • Fix ExFactoryPrice
  • Prepare for new Selbstbehalt 10%->20% and 20%->40%
  • Keep in Mind

Commits

oddb.org:

yus:

ydbi and ydbi-pg:

  • 0.6.0 released
  • To release the 0.6.0 ydbi-pg gem I had to run manually the following commands bundle exec rake ydbd-pg:package; cd pkg; gem push ydbd-pg-0.6.0.gem

Index

Fix ydbi to work with newer postgresql version

  • Added changelog_uri to gemspec
  • Fixed problem with pg_attrdef.adsrc which was not supported on postgresql 12 and newer
  • Ensure that bundle exec rake still works with postgresql 10
  • Made dbd tests work again (with two omission)
  • Added ruby 3.3 to github test workflow

Assert that various gem neede by oddb.org work under Ruby 3.3

Added some simple changes to the following gems to make the work under ruby 3.3 and run the test in the github workflow test actions.

  • spreadsheet
  • sbsm
    • Use Logger (with file output) instead of obsolete ChronoLogger
    • release version 1.6.2
    • Run tests for ruby 3.3 in the github workflow
    • Add changelog_uri to gemspec
    • Added devenv for ruby 3.3
  • htmlgrid
    • Run tests for ruby 3.3 in the github workflow
    • Add changelog_uri to gemspec
    • Added devenv for ruby 3.3
  • swissmedic-diff
    • Run tests for ruby 3.3 in the github workflow
    • Add changelog_uri to gemspec
    • Added devenv for ruby 3.3
  • yus
    • Run tests for ruby 3.3 in the github workflow
    • Add changelog_uri to gemspec
    • Added devenv for ruby 3.3
  • odba
    • Run tests for ruby 3.3 in the github workflow
    • Add changelog_uri to gemspec
    • Added devenv for ruby 3.3
  • migel
    • Run tests for ruby 3.3 in the github workflow
    • Add changelog_uri to gemspec
    • Added devenv for ruby 3.3
    • update to use ydbi and ydbd-pg 0.6.0

Port oddb.org to Ruby 3.3

I have the following error when accessing the http 192.168.0.75:8012

Internal Server Error
wrong number of arguments (given 2, expected 1)
WEBrick/1.8.1 (Ruby/3.3.0/2023-12-25) at 192.168.0.75:8012

Using the debug gem and going up to found

[91, 100] in /opt/src/oddb.org/.devenv/state/.bundle/ruby/3.3.0/gems/webrick-1.8.1/lib/webrick/httpserver.rb
    91|           elsif callback = server[:RequestHandler]
    92|             msg = ":RequestHandler is deprecated, please use :RequestCallback"
    93|             @logger.warn(msg)
    94|             callback.call(req, res)
    95|           end
=>  96|           server.service(req, res)
    97|         rescue HTTPStatus::EOFError, HTTPStatus::RequestTimeout => ex
    98|           res.set_error(ex)
    99|         rescue HTTPStatus::Error => ex
   100|           @logger.error(ex.message)
  #0    Rack::BodyProxy#respond_to_missing? at /opt/src/oddb.org/.devenv/state/.bundle/ruby/3.3.0/gems/rack-3.0.8/lib/rack/body_proxy.rb:21
  #1    Rack::BodyProxy#respond_to_missing?(method_name=:to_path, include_all=false) at /opt/src/oddb.org/.devenv/state/.bundle/ruby/3.3.0/gems/rack-3.0.8/lib/rack/body_proxy.rb:17
  # and 8 frames (use `bt' command for all frames)

Tried to revert the version of rack, rackup and webrick to the old version. Still the same error.

After spending quite a few hours I found the following errors

Internal Server Error
wrong number of arguments (given 2, expected 1)
WEBrick/1.8.1 (Ruby/3.3.0/2023-12-25) at 192.168.0.75:8012

Once this changes made, my ruby 3.2 and 3.3 branches started up without problems and allowed me to see the stuff like http://127.0.0.1:8012/de/gcc/fachinfo/reg/45011. But when trying to log in I get the error

 DRb::DRbConnError at /de/gcc
drbssl://127.0.0.1:9997 - #<OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=107 peeraddr=(null) state=error: unexpected eof while reading>
Ruby 	/nix/store/yfdhpdln024hy1icv1h5r6bk8d92xihl-ruby-3.3.0/lib/ruby/3.3.0/drb/drb.rb: in rescue in block in open, line 744
Web 	POST 127.0.0.1/de/gcc

Now working on fixing this error and running my first spec test bundle exec rspec spec/smoketest_spec.rb:632. Here I must improve my devenv to include the needed tools, like firefox, chromium, and fixing the DRB connection problem.

When the spec test tries to login I have the following stacktrace

DRb::DRbConnError: drbssl://127.0.0.1:9997 - #<OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=107 peeraddr=(null) state=error: unexpected eof while reading>
        /nix/store/yfdhpdln024hy1icv1h5r6bk8d92xihl-ruby-3.3.0/lib/ruby/3.3.0/drb/drb.rb:744:in `rescue in block in open'
        /nix/store/yfdhpdln024hy1icv1h5r6bk8d92xihl-ruby-3.3.0/lib/ruby/3.3.0/drb/drb.rb:738:in `block in open'
        /nix/store/yfdhpdln024hy1icv1h5r6bk8d92xihl-ruby-3.3.0/lib/ruby/3.3.0/drb/drb.rb:737:in `each'
        /nix/store/yfdhpdln024hy1icv1h5r6bk8d92xihl-ruby-3.3.0/lib/ruby/3.3.0/drb/drb.rb:737:in `open'
        /nix/store/yfdhpdln024hy1icv1h5r6bk8d92xihl-ruby-3.3.0/lib/ruby/3.3.0/drb/drb.rb:1319:in `initialize'
        /nix/store/yfdhpdln024hy1icv1h5r6bk8d92xihl-ruby-3.3.0/lib/ruby/3.3.0/drb/drb.rb:1302:in `new'
        /nix/store/yfdhpdln024hy1icv1h5r6bk8d92xihl-ruby-3.3.0/lib/ruby/3.3.0/drb/drb.rb:1302:in `open'
        /nix/store/yfdhpdln024hy1icv1h5r6bk8d92xihl-ruby-3.3.0/lib/ruby/3.3.0/drb/drb.rb:1143:in `block in method_missing'
        /nix/store/yfdhpdln024hy1icv1h5r6bk8d92xihl-ruby-3.3.0/lib/ruby/3.3.0/drb/drb.rb:1162:in `with_friend'
        /nix/store/yfdhpdln024hy1icv1h5r6bk8d92xihl-ruby-3.3.0/lib/ruby/3.3.0/drb/drb.rb:1142:in `method_missing'
        /opt/src/oddb.org/src/util/oddbapp.rb:1641:in `login'
        /opt/src/oddb.org/src/util/session.rb:115:in `login'
        /opt/src/oddb.org/src/state/admin/login.rb:17:in `login'
        /opt/src/oddb.org/.devenv/state/.bundle/ruby/3.3.0/gems/sbsm-1.6.1/lib/sbsm/state.rb:198:in `_trigger'
        /opt/src/oddb.org/src/state/global.rb:1020:in `_trigger'

Turns out that we need to regenerate the yus certificates because the ones stored under yus/data are way too old (from 2006). The has been remarked several times by several people, eg. Niklaus ruby-3.1 Solution committed via devenv: bundle install and create valid data/yus.key

Running bundle exec rspec spec has 1037 examples, 101 failures, 267 pending. Many domain tests fail, eg. https://phytotherapeutika.ch with an error the domain name does not match the certificat.

All failing domain names are:

rspec ./spec/domaintest_spec.rb[1:2] # ch.oddb.org should work with https://anthroposophika.ch
rspec ./spec/domaintest_spec.rb[1:3] # ch.oddb.org should work with https://anthroposophika.oddb.org
rspec ./spec/domaintest_spec.rb[1:4] # ch.oddb.org should work with https://anthroposophy.oddb.org
rspec ./spec/domaintest_spec.rb[1:5] # ch.oddb.org should work with https://desitin.ch.oddb.org
rspec ./spec/domaintest_spec.rb[1:7] # ch.oddb.org should work with https://epilepsie-therapie.ch
rspec ./spec/domaintest_spec.rb[1:9] # ch.oddb.org should work with https://generika.oddb.org
rspec ./spec/domaintest_spec.rb[1:10] # ch.oddb.org should work with https://homeopathy.oddb.org
rspec ./spec/domaintest_spec.rb[1:11] # ch.oddb.org should work with https://homoeopathika.oddb.org
rspec ./spec/domaintest_spec.rb[1:12] # ch.oddb.org should work with https://i.ch.oddb.org
rspec ./spec/domaintest_spec.rb[1:13] # ch.oddb.org should work with https://i.oddb.org
rspec ./spec/domaintest_spec.rb[1:15] # ch.oddb.org should work with https://mobile.ch.oddb.org
rspec ./spec/domaintest_spec.rb[1:16] # ch.oddb.org should work with https://mobile.oddb.org
rspec ./spec/domaintest_spec.rb[1:17] # ch.oddb.org should work with https://nachahmer.ch
rspec ./spec/domaintest_spec.rb[1:18] # ch.oddb.org should work with https://new.ch.oddb.org
rspec ./spec/domaintest_spec.rb[1:19] # ch.oddb.org should work with https://oddb.org
rspec ./spec/domaintest_spec.rb[1:21] # ch.oddb.org should work with https://phyto-pharma.ch
rspec ./spec/domaintest_spec.rb[1:22] # ch.oddb.org should work with https://phyto-pharma.oddb.org
rspec ./spec/domaintest_spec.rb[1:23] # ch.oddb.org should work with https://phytotherapeutika.ch
rspec ./spec/domaintest_spec.rb[1:24] # ch.oddb.org should work with https://ramaze.ch.oddb.org
rspec ./spec/domaintest_spec.rb[1:25] # ch.oddb.org should work with https://santesuisse.oddb.org
rspec ./spec/domaintest_spec.rb[1:26] # ch.oddb.org should work with https://www.anthroposophica.ch
rspec ./spec/domaintest_spec.rb[1:27] # ch.oddb.org should work with https://www.anthroposophika.ch
rspec ./spec/domaintest_spec.rb[1:28] # ch.oddb.org should work with https://www.ch.oddb.org
rspec ./spec/domaintest_spec.rb[1:29] # ch.oddb.org should work with https://www.oddb.org
rspec ./spec/domaintest_spec.rb[1:30] # ch.oddb.org should work with https://www.phyto-pharma.ch
rspec ./spec/domaintest_spec.rb[1:31] # ch.oddb.org should work with https://www.phytotherapeutika.ch
rspec ./spec/domaintest_spec.rb[1:32] # ch.oddb.org should work with https://www.xn--homopathika-tfb.ch
rspec ./spec/domaintest_spec.rb[1:33] # ch.oddb.org should work with https://xn--homopathika-tfb.ch
rspec ./spec/domaintest_spec.rb[1:34] # ch.oddb.org should work with https://xn--homopathika-tfb.oddb.org

Probably many are no longer used. Other errors would justify looking at. Probably some names/contents have changed.

Fix ExFactoryPrice

Debugging using bundle exec ruby jobs/import_bsv. Also creating a new unit test with only the nasonex preparation. The new field LastPriceChange in ExFactoryPrice confuses the import and must be handled correctly. Reworking the unit test to enable parsing parts of the Preparations.xml. After running import_bsv several times and adding some debug info, I think a changed price does not get stored in the package and we have to insert an explicit @pack.odba call. Now the price gets updated but the valid_from is 1998 and not 2024!

Verified this using bin/admin after a successful bsv_import

-> #<ODDB::Package:0x00007f9df53dbcc0>
ch.oddb> $packs = packages.find_all{|x|x.iksnr.to_i == 54189}
-> [#<ODBA::Stub:5624520#1163817 @odba_class= @odba_container=737260#1163812>]
ch.oddb> $packs.size
-> 1
ch.oddb> $packs.first
-> #<ODDB::Package:0x00007f9df53dbcc0>
ch.oddb> $packs.first.oid
-> 1163817
ch.oddb> $packs.first.name
-> Nasonex, Dosier-Nasenspray
ch.oddb> $packs.first.price_public
-> 18.00
ch.oddb> $packs.first.price_public.valid_from
-> 1998-03-15 00:00:00 +0100
ch.oddb> $packs.first.price_exfactory.valid_from
-> 2024-01-01 00:00:00 +0100
ch.oddb> $packs.first.price_exfactory.amount
-> 8.5

Conclusion: Must fix update price_exfactory! Adding the test in my unit test makes it fail. Thats good! Struggled a while till I discovered quite a good solution by adding a new variable parsing_prices, as the date in the XML-element Status.ValidFromDate overrote the PublicPrice.ValidFromDate.

After running bsp_import I still have the following display in http://localhost:8012/de/gcc/price_history/reg/54189/seq/02/pack/036 15.03.1998 18.00 SL http://www.xn--spezialittenliste-yqb.ch/File.axd?file=XMLPublications.zip (01.01.2024) Freiwillige Preissenkung. Banging my head, why the ExFactory-Price is not updated. Adding some binding.debug statement for iksnr 54189 in bsv_xml.rb. Looks like in the tag_end for ValidFromDate for the status we overwrite also the ValidFromDate of the price and maybe even the price. Or do we overwrite it in the tag_end for preparation. Adding some condition debugger for this iksnr in these 3 tag_end and restarting bsp_import. But now I am fighting with the debugger. Going into a break point does not work. Error StackLevel to deep, > 8000 levels. Turns out that I did not set in the package the prices correctly. Found by adding in my unit_test the line assert_equal(true, packs.first.has_price_history?)

To check what works or not I ran under bin/admin

$nasovan = packages.find{|x|x.iksnr.to_i == 54189}
$nasovan.price_public = Util::Money.new(20, @price_type, 'CH')
$nasovan.price_exfactory = Util::Money.new(10, @price_type, 'CH')
$nasovan.price_exfactory.valid_from = Time.new(2022,1,31)
$nasovan.price_public.valid_from = Time.new(2022,1,31)

Without a oddb.org restart, I immediately did see under http://localhost:8012/de/gcc/price_history/reg/54189/seq/02/pack/036

31.01.2022 9.09 (+0.00 %) 20.00 (+7.24 %) SL http://bag.e-mediat.net/SL2007.Web.External/File.axd?file=XMLPublications.zip (01.02.2018) Freiwillige Preissenkung

But somehow the price_exfactory is not correct, even when bin/admin shows 10.00 for $nasovan.exfactory_price. Restarting oddb.org and checking again.

Now under http://localhost:8012/de/gcc/search/zone/drugs/search_query/nasonex/search_type/st_sequence?#best_result I see

FI PI Nasonex 140 Einzeldosen 10.00 20.00 20% Nasenspray: Mometasoni-17 Furoas Organon GmbH B / SL / SO FB Twitter G tell a friend

But I still have http://localhost:8012/de/gcc/price_history/reg/54189/seq/02/pack/036 with

31.01.2022 9.09 (+0.00 %) 20.00 (+7.24 %) SL http://bag.e-mediat.net/SL2007.Web.External/File.axd?file=XMLPublications.zip (01.02.2018) Freiwillige Preissenkung

As documented under https://github.com/zdavatz/oddb.org/issues/240#issuecomment-1932371433 the current price_public.valid_from is not updated when the current valid_from is different. It was easy to add this example to my unit tests. Running bsv_import again and waiting for the result.

Looks like it works, but in https://ch.oddb.org/de/gcc/price_history/reg/66015/seq/01/pack/011 we see the changes in the VAT

01.01.2024	 	 	58.60	(+0.09 %)	SL	http://www.xn--spezialittenliste-yqb.ch/File.axd?file=XMLPublications.zip (01.01.2024)	MWSTAENDERUNG
01.12.2020	36.71	 	58.55	 	SL	http://www.xn--spezialittenliste-yqb.ch/File.axd?file=XMLPublications.zip (01.12.2020)	Erstaufnahme in die SL

Whereas my first solution silently overwrites it and gives

01.12.2020	36.71	 	58.55	(+0.00 %)	SL	http://www.xn--spezialittenliste-yqb.ch/File.axd?file=XMLPublications.zip (01.12.2020)	Erstaufnahme in die SL

By debugging in the src/state/drugs/price_history.rb I found the following three prices

exfactory Added 2020-12-01 00:00:00 +0100 ex 36.71  pub 
public Added 2020-12-01 00:00:00 +0100 ex 36.71  pub 58.60
public Added 2020-12-01 00:00:00 +0100 ex 36.71  pub 58.55

Must think about how to handle this. Maybe we must handle the tag PriceChangeTypeCode with MWSTAENDERUNG differently.

Prepare for new Selbstbehalt

This looks easy. For displaying we just need to modify src/custom/lookandfeelbase.rb by updating :deductible_g and :deductible_o.

For parsing correctly we can use a backward compatible solution for src/plugin/bsv_xml by using a regular expression to match the old FlagSB20 and new new FlagSB. Will do this work once I complete the problem with the exfactory prices.

view · edit · sidebar · attach · print · history
Page last modified on February 07, 2024, at 06:20 PM