<< Masa.20110829-import-fr_data-migel-drb-client-oddb_org | 2011 | Masa.20110825-limitation-feedback-email-links-migel-drb-client-oddb_org >>
Goal/Estimate/Evaluation:
suspend
Note
masa@masa ~/ywesee/oddb.org $ bin/oddbd /usr/lib64/ruby/gems/1.8/gems/gd2-1.1.1/lib/gd2.rb:58:in `initialize': libpng12.so.0: cannot open shared object file: No such file or directory (RuntimeError) from /usr/lib64/ruby/gems/1.8/gems/gd2-1.1.1/lib/gd2.rb:58:in `dlopen' from /usr/lib64/ruby/gems/1.8/gems/gd2-1.1.1/lib/gd2.rb:58 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib64/ruby/gems/1.8/gems/turing-0.0.11/lib/turing/image.rb:13 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /usr/lib64/ruby/gems/1.8/gems/turing-0.0.11/lib/turing.rb:34 ... 8 levels... from /home/masa/ywesee/oddb.org/src/util/oddbapp.rb:9 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from bin/oddbd:9
Reinstall libpng old version
$ ls /usr/portage/media-libs/libpng/ ChangeLog libpng-1.4.5.ebuild libpng-1.5.2.ebuild metadata.xml libpng-1.2.44.ebuild libpng-1.4.7.ebuild Manifest $ sudo emerge =media-libs/libpng-1.2.44
Result
Problem
migel> Migel::Importer.new.update('data/csv/migel_de_test.csv', 'de') -> /usr/lib64/ruby/1.8/drb/drb.rb:395:in `_dump': can't dump
Solution
class Multilingual #include DRb::DRbUndumped
def search_limitation(migel_code) case migel_code.length when 2 # Group if group = Migel::Model::Group.find_by_migel_code(migel_code) ODBA::DRbWrapper.new(group.limitation_text) end when 5 # Subgroup if subgroup = Migel::Model::Subgroup.find_by_migel_code(migel_code) ODBA::DRbWrapper.new(subgroup.limitation_text) end else # Migelid if migelid = Migel::Model::Migelid.find_by_migel_code(migel_code) ODBA::DRbWrapper.new(migelid.limitation_text) end end end
def search_migel_limitation(migel_code) code = migel_code.split(/(\d\d)/).select{|x| !x.empty?}.join('.') MIGEL_SERVER.search_limitation(code) end
Access
Result
undefined method `de' for #<DRb::DRbUnknown:0x7ffb597630c0> /home/masa/ywesee/oddb.org/src/view/migel/product.rb:82:in `send' /home/masa/ywesee/oddb.org/src/view/migel/product.rb:82:in `description' /home/masa/ywesee/oddb.org/src/view/migel/product.rb:103:in `limitation_text' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:66:in `send' /usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:66:in `create'
Experiment
def limitation_text(update = false) if update @limitation_text ||= Migel::Util::Multilingual.new else if @limitation_text ODBA::DRbWrapper.new(@limitation_text) end end end
def limitation_text(update = false) if update @limitation_text ||= Migel::Util::Multilingual.new else if @limitation_text ODBA::DRbWrapper.new(@limitation_text) end end end
Result
Experiment
module Migel module Model class Product < ModelSuper odba_index :pharmacode odba_index :ean_code odba_index :article_name odba_index :companyname end end end
Restore database
$ sudo -u postgres dropdb migel $ sudo -u postgres createdb -E UTF8 -T template0 migel $ bin/migeld
migel> Migel::Importer.new.update('data/csv/migel_de_test.csv', 'de') migel> Migel::Importer.new.update_products_by_migel_code('15.30.50.00.1')
Run
migel> Migel::Model::Product.search_by_article_name('CONTAM Vaginaltampon 26mm regular')[0].pharmacode -> 2126923 migel> Migel::Model::Product.search_by_article_name('CONTAM Vaginaltampon 26mm regular').length -> 1 migel> Migel::Model::Product.search_by_article_name('CONTAM Vaginaltampon 26mm regular')[0].class -> Migel::Model::Product migel> Migel::Model::Product.search_by_article_name('CONTAM Vaginaltampon 26mm regular')[0].pharmacode -> 2126923 migel> Migel::Model::Product.find_by_pharmacode('2126923').article_name -> CONTAM Vaginaltampon 26mm regular migel> Migel::Model::Product.search_by_article_name('CONTAM Vaginaltampon').length -> 4
Note
Next
Problem
Idea
Experiment
def search ... when :migel if result = @session.search_migel_products(query) and !result.empty? State::Migel::Result.new(@session, result) elsif result = @session.app.search_migel_items(query) and !result.empty? State::Migel::Items.new(@session, result) else State::Migel::Result.new(@session, []) end
def search_migel_items(query) MIGEL_SERVER.product.search_by_article_name(query) + MIGEL_SERVER.product.search_by_companyname(query) end
Search (z.B. 'CONTAM')
Result
Note
Refer to
Create test data (Similar company name but different migel code)
migel> Migel::Model::Migelid.find_by_migel_code('15.11.01.00.1').products.push Migel::Model::Product.new('1234567') -> migel> Migel::Model::Migelid.find_by_migel_code('15.11.01.00.1').save -> Stück migel> Migel::Model::Migelid.find_by_migel_code('15.11.01.00.1').products[0].migelid = Migel::Model::Migelid.find_by_migel_code('15.11.01.00.1') -> Stück migel> Migel::Model::Migelid.find_by_migel_code('15.11.01.00.1').products[0].save -> migel> Migel::Model::Migelid.find_by_migel_code('15.11.01.00.1').products[0].class -> Migel::Model::Product migel> Migel::Model::Migelid.find_by_migel_code('15.11.01.00.1').products[0].migelid.migel_code -> 15.11.01.00.1 migel> Migel::Model::Migelid.find_by_migel_code('15.11.01.00.1').products[0].pharmacode -> 1234567 migel> Migel::Model::Migelid.find_by_migel_code('15.11.01.00.1').products[0].article_name = 'CONTAM Vaginaltampon 22mm mini 10 Stk' -> CONTAM Vaginaltampon 22mm mini 10 Stk migel> Migel::Model::Migelid.find_by_migel_code('15.11.01.00.1').products[0].save -> CONTAM Vaginaltampon 22mm mini 10 Stk migel> Migel::Model::Migelid.find_by_migel_code('15.11.01.00.1').products[0].article_name -> CONTAM Vaginaltampon 22mm mini 10 Stk
Experiment
class SearchedList < HtmlGrid::List .... def compose_list(model = @model, offset=[0,0]) # Grouping products with migel_code migel_code_group = {} model.each do |product| (migel_code_group[product.migel_code] ||= []) << product end # list up items migel_code_group.keys.each do |migel_code| offset_length = migel_code_group[migel_code].length compose_subheader(migel_code_group[migel_code][0], offset) super(migel_code_group[migel_code], offset) offset[1] += offset_length end end def compose_subheader(item, offset, css='list atc') subheader = SubHeader.new(item, @session, self) @grid.add(subheader, *offset) @grid.set_colspan(offset.at(0), offset.at(1), full_colspan) offset[1] += 1 end
Search migel by company name
Result
Restore and import
masa@masa ~/ywesee/migel $ sudo -u postgres dropdb migel masa@masa ~/ywesee/migel $ sudo -u postgres createdb -E UTF8 -T template0 migel masa@masa ~/ywesee/migel $ bin/migeld
migel> Migel::Importer.new.update('data/csv/migel_de.csv', 'de') migel> Migel::Importer.new.update('data/csv/migel_fr.csv', 'fr') migel> Migel::Importer.new.update_all_products true
Let's see the result on Monday...