view · edit · sidebar · attach · print · history

20160913-debug-sandoz-bbmb-ch-data-duplication

<< | Index | 20160913-migrate-steinwies-ch >>


Summary

  • Fix duplicated strange data (some products does not have price, again)
  • Fix different article number issue (some products hase different article number against same pharmacode)

Commits / Patches / Pull Requests, Scripts

Index


Debug sandoz.bbmb.ch data

Customer can't order 5117072 and 4996172

ch.bbmb.sandoz> BBMB::Model::Product.find_by_pcode('4996172').pcode
-> 4996172
ch.bbmb.sandoz> BBMB::Model::Product.find_by_pcode('5117072').pcode
-> 5117072

INDEX has 3 products for 5117072. This was problem.

ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_product_pcode', '').select {|p| p.pcode == '4996172' }.length
-> 1
ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_product_pcode', '').select {|p| p.pcode == '5117072' }.length
-> 3

I think that we have recently already solved non-thread safe issue.
Then I've chedk, how many strange products in database?

ch.bbmb.sandoz> v = []; File.read('./phar.txt').each_line {|l| \
v << l.chop if ODBA.cache.retrieve_from_index('bbmb_model_product_pcode', '').select {|p| \
p.pcode == l.chop }.length != 1 }; v.length
-> 56

These products come from Artikel.txt.
In Artikel.txt:

  • Some products does not have pharmacode
  • Some products changes Artikle number against same pharmacode (This was problem)

1. Create phar.txt (pharmacode only text file from newest Artikel.txt) 2. Put phar.txt into /var/www/sandoz.bbmb.ch 3. Count duplicated products with pharmacode via bin/admin 4. Check these products

# How to count duplicated products from file.
ch.bbmb.sandoz> v = []; File.read('/var/www/sandoz.bbmb.ch/phar.txt').each_line {|l| next if l.chop.empty?; \
c = ODBA.cache.retrieve_from_index('bbmb_model_product_pcode', '').select {|p| \
p.pcode == l.chop }.length; v << l.chop if c > 1 }; p v
-> Array

This is a result on production

["1301904", "4124733", "2366082", "1421146", "2324014", "2315506", "2872112",
"2991265", "2991259", "4124733", "4844628", "6479647", "1301867", "2991265",
"2991259", "1421146", "1301904", "2324014", "2366082", "2872112", "2315506", "2508406"]

It seems that these products have some article code.

z.B. 1301904 has different article number.
ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_product_pcode', '').select {|p| \
p.pcode == '1301904' }[0].article_number
-> 00544207
ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_product_pcode', '').select {|p| \
p.pcode == '1301904' }[1].article_number
-> 44019496

z.B. 4124733 has different article number.
ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_product_pcode', '').select {|p| \
p.pcode == '4124733' }[0].article_number
-> 44015832
ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_product_pcode', '').select {|p| \
p.pcode == '4124733' }[1].article_number
-> 44065395

How to delete these (all) products

ch.bbmb.sandoz> ["1301904", "4124733", "2366082", "1421146", "2324014", \
 "2315506", "2872112", "2991265", "2991259", "4124733", "4844628", "6479647", \
"1301867", "2991265", "2991259", "1421146", "1301904", "2324014", "2366082", \
"2872112", "2315506", "2508406"].map {|pcode| ODBA.cache.retrieve_from_index('bbmb_model_product_pcode', '').select {|p| \
p.pcode == pcode }.map {|p| p.odba_delete } }

And run (improved) update.
Then

ch.bbmb.sandoz> ODBA.cache.retrieve_from_index('bbmb_model_product_pcode', '').select {|p| p.pcode == "1301904" }.length
-> 1

Commits:

view · edit · sidebar · attach · print · history
Page last modified on September 13, 2016, at 05:37 PM