<< | Index | >>
suspend
suspend
Email ch.ODDB.org Report - Updated Migel Nonpharma - 08/2011
Updated MiGel items: 29943 /var/www/oddb.org/data/csv/swissINDEX_MiGel.csv swissINDEX_MiGel.csv 4902K
Note
Problem
def migel_code(model) if items = model.items and !items.empty? link = PointerLink.new(:to_s, model, @session, self) link.value = model.migel_code link.href = @lookandfeel._event_url(:migel_search, {:migel_code => model.migel_code.gsub(/\./, '')}) link elsevalue = HtmlGrid::Value.new(:to_s, model, @session)
value.value = model.migel_code
value
end end
Result
Note
Consideration
Problem
Solution
Next
Experiment
def merge_swissindex_migel(swissindex_item, migel_line) # Swissindex data swissindex = swissindex_item.collect do |key, value| case key when :gtin [:ean_code, value] when :dt [:datetime, value] when :lang [:language, value] when :dscr [:article_name, value] when :addscr [:size, value] when :comp [:compnayname, value[:name], :companyean, value[:gln]] else [key, value] end end swissindex = Hash[*swissindex.flatten] # Migel data pharmacode, article_name, companyname, ppha, ppub, factor, pzr = *migel_line migel = { :pharmacode => pharmacode, :article_name => article_name, :companyname => companyname, :ppha => ppha, :ppub => ppub, :factor => factor, :pzr => pzr, } migel.update swissindex end def search_item_with_swissindex_migel(pharmacode) migel_line = search_migel(pharmacode) if swissindex_item = search_item(pharmacode) merge_swissindex_migel(swissindex_item, migel_line) else merge_swissindex_migel({}, migel_line) end end
def search_item(pharmacode) item = {} SWISSINDEX_NONPHARMA_SERVER.session(ODDB::Swissindex::SwissindexNonpharma) do |swissindex| item = swissindex.search_item_with_swissindex_migel(pharmacode) end item end
# This is just to update items which do not have article_name def update_items_again_by_pharma(time_estimate = false) total = @app.migel_count start_time = Time.now @count_updated_item = 0 @output_file = nil plugin = ODDB::SwissindexNonpharmaPlugin.new(@app) @app.migel_products.each_with_index do |product, count| if items = product.items items.each do |pharmacode, item| unless item.article_name item_record = plugin.search_item(pharmacode) update_item(product, item_record) @count_updated_item += 1 end end end puts estimate_time(start_time, total, count + 1) if time_estimate end return true end
Run
ch.oddb> ODDB::MiGeLPlugin.new(self).update_items_again_by_pharma
Result
Problem
Note
Cause
Directly rewrite /etc/crontab
1 23 2 * * user /var/www/oddb.org/jobs/import_migel_nonpharma
#!/usr/bin/env ruby # must be scheduled in crontab to run as the same user as oddb $: << File.expand_path('../src', File.dirname(__FILE__)) $: << File.expand_path('..', File.dirname(__FILE__)) require 'util/job' require 'util/updater' module ODDB module Util Job.run do |system| Updater.new(system).update_migel_nonpharma end end end
Run
ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.length end}; c -> 29943 ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| it.is_a?(ODDB::Migel::Item) }.length end}; c -> 29943 ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| it.ean_code}.length end}; c -> undefined method `ean_code' for #<Array:0x7f010487f440> ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| !it.is_a?(Array) && !it.is_a?(Part) && !it.is_a?(Package) && !it.is_a?(ActiveAgent) && !it.is_a?(Composition) && !it.is_a?(Hash) && !it.is_a?(Sequence) && it.ean_code }.length end}; c -> 24467
Note
More
ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| it.is_a?(Array) }.length end}; c -> 15 ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| it.is_a?(Part)}.length end}; c -> 9 ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| it.is_a?(Package)}.length end}; c -> 3 ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| it.is_a?(ActiveAgent)}.length end}; c -> 4 ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| it.is_a?(Composition)}.length end}; c -> 3 ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| it.is_a?(Hash)}.length end}; c -> 4 ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| it.is_a?(Sequence)}.length end}; c -> 3 ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| it.is_a?(Array) or it.is_a?(Part) or it.is_a?(Package) or it.is_a?(ActiveAgent) or it.is_a?(Composition) or it.is_a?(Hash) or it.is_a?(Sequence)}.length end}; c -> 41 ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| it.is_a?(ODDB::Migel::Item)}.length end}; c -> 29943 ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| (it.is_a?(Array) or it.is_a?(Part) or it.is_a?(Package) or it.is_a?(ActiveAgent) or it.is_a?(Composition) or it.is_a?(Hash) or it.is_a?(Sequence)) and it.is_a?(ODDB::Migel::Item)}.length end}; c -> 41 ch.oddb> c=0; migel_products.each{|pr| if items=pr.items then c+=items.values.select{|it| it.is_a?(Array) and it.is_a?(ODDB::Migel::Item)}.length end}; c -> 15
Consideration
More
ch.oddb> a=nil; migel_products.each{|pr| if items=pr.items then items.values.each{|it| if it.is_a?(Array) then a=it end} end}; a.class -> ODDB::Migel::Item ch.oddb> a=nil; migel_products.each{|pr| if items=pr.items then items.values.each{|it| if it.is_a?(Array) then a=it end} end}; a.article_name -> undefined method `article_name' for #<Array:0x7f010473de38> ch.oddb> a=nil; migel_products.each{|pr| if items=pr.items then items.values.each{|it| if it.is_a?(Array) then a=it end} end}; a.length -> 3 ch.oddb> a=nil; migel_products.each{|pr| if items=pr.items then items.values.each{|it| if it.is_a?(Array) then a=it end} end}; a[0] -> Aliskirenum 300 mg ch.oddb> a=nil; migel_products.each{|pr| if items=pr.items then items.values.each{|it| if it.is_a?(Array) then a=it end} end}; a[1] -> Amlodipinum 10 mg ch.oddb> a=nil; migel_products.each{|pr| if items=pr.items then items.values.each{|it| if it.is_a?(Array) then a=it end} end}; a[2] -> Hydrochlorothiazidum 12.5 mg ch.oddb> a=nil; migel_products.each{|pr| if items=pr.items then items.values.each{|it| if it.is_a?(Array) then a=it end} end}; a[2].class -> ODDB::ActiveAgent ch.oddb> a=nil; migel_products.each{|pr| if items=pr.items then items.values.each{|it| if it.is_a?(Array) then a=it end} end}; a[1].class -> ODDB::ActiveAgent ch.oddb> a=nil; migel_products.each{|pr| if items=pr.items then items.values.each{|it| if it.is_a?(Array) then a=it end} end}; a[0].class -> ODDB::ActiveAgent ch.oddb> a=nil; migel_products.each{|pr| if items=pr.items then items.values.each{|it| if it.is_a?(Array) then a=it end} end}; a[0].pointer -> :!registration,61678!sequence,03!composition,27218368!active_agent,Aliskirenum. ch.oddb> registration('61678').sequence('03').compositions[0].active_agents[0].pointer -> :!registration,61678!sequence,03!composition,27218368!active_agent,Aliskirenum.
Consideration
ch.oddb> a=nil; migel_products.each{|pr| if items=pr.items then items.values.each{|it| if it.is_a?(Array) then a=it end} end}; a.class -> ODDB::Migel::Item ch.oddb> a=nil; migel_products.each{|pr| if items=pr.items then items.values.each{|it| if it.is_a?(Array) then a=it end} end}; a.article_name -> undefined method `article_name' for #<Array:0x7f010473de38>
Conclusion
Commit
Experiment
Result
Next
def search zone = @session.zone ... case zone ... when :migel result = @session.search_migel_products(query) State::Migel::Result.new(@session, result)
Note
Next