<< Masa.20101214-update-bbmb-ch | 2010 | Masa.20101210-report-export-fachinfo_yaml >>
Confirm the current process
Run
Run export_fachinfos by using bin/admin
masa@masa ~/ywesee/oddb.org $ bin/admin ch.oddb> YamlExporter.new(self).export_fachinfos
Result
Restore the old data on the cache
masa@masa ~/ywesee/oddb.org $ sudo -u postgres dropdb oddb.org masa@masa ~/ywesee/oddb.org $ sudo -u postgres createdb -E UTF8 -T template0 oddb.org masa@masa ~/ywesee/oddb.org.bak.20101210_3_report_process_fachinfo_yaml/data/sql $ zcat oddb.org.20101209.sql.gz |psql -U postgres oddb.org
Run YamlExporter#export_fachinfos again
Result
Message: YamlExporter#export_fachinfs method is still running, but I found some missing Fachinfo document data. This may cause an error in export ebooks process of ebps. There is no 'fr' description of Fachinformation of the following Swissmedic Registration Number: 56811, 58417, 53183, 00610, 00528
Next
Experiment
def export_fachinfos(name='fachinfo.yaml')
# Check missing data of fachinfo data
no_descr = {'de' => [], 'fr' => []}
@app.fachinfos.values.each do |fachinfo|
no_descr.keys.each do |language|
unless fachinfo.descriptions[language]
swissmedic_registration_numbers = ODBA.cache.fetch(fachinfo.odba_id, nil).iksnrs
no_descr[language].push(
[fachinfo.company_name, fachinfo.name_base].concat(swissmedic_registration_numbers)
)
end
end
end
# Send a warning report of fachinfo description
if no_descr.values.flatten.length > 0
log = Log.new(@@today)
message = []
no_descr.keys.each do |language|
unless no_descr[language].empty?
i = 0
message.concat([
"There is no '#{language}' description of Fachinformation of the following",
"Swissmedic Registration (Company, Product, Numbers):",
no_descr[language].map{|fachlist| " " + (i+=1).to_s + ". " + fachlist.join(", ") + "\n"}.to_s
])
end
end
log.report = [
"Message: ",
"YamlExporter#export_fachinfs method is still running,",
"but I found some missing Fachinfo document data.",
"This may cause an error in export ebooks process of ebps.",
"",
].concat(message).join("\n")
log.notify(" Warning Export: #{name}")
end
# Go to actual exporting process
export_array(name, @app.fachinfos.values)
end
Reboot oddbd, exportd
Run YamlExporter#export_fachinfs
Message: YamlExporter#export_fachinfs method is still running, but I found some missing Fachinfo document data. This may cause an error in export ebooks process of ebps. There is no 'fr' description of Fachinformation of the following Swissmedic Registration (Company, Product, Numbers): 1. Sandoz Pharmaceuticals AG, Amicosol 1,2 g (1000/200), 56811 2. Axapharm AG, Muco-X 200, 58417 3. Tentan AG, Imucal, 53183 4. Sanofi Pasteur MSD AG, Gen H-B-Vax 5, 00610, 00528
Commit
Check current test
masa@masa ~/ywesee/oddb.org $ vim src/plugin/yaml.rb masa@masa ~/ywesee/oddb.org $
Note
Experiment (remove comments)
Run test
masa@masa ~/ywesee/oddb.org $ ruby test/test_plugin/yaml.rb test/test_plugin/yaml.rb:144: uninitialized constant ODDB::Package (NameError)
Note
Check git history
Consideration
Note
Template test/test_plugin/yaml.rb
#!/usr/bin/env ruby
# TestYamlPlugin -- oddb -- 02.09.2003 -- rwaltert@ywesee.com
$: << File.expand_path('..', File.dirname(__FILE__))
$: << File.expand_path("../../src", File.dirname(__FILE__))
require 'test/unit'
require 'plugin/yaml'
require 'flexmock'
module ODDB
class YamlExporter < Plugin
remove_const :EXPORT_DIR
EXPORT_DIR = File.expand_path('../data/export', File.dirname(__FILE__))
end
class TestYamlExporter < Test::Unit::TestCase
include FlexMock::TestCase
def test_export_fachinfos
assert(true)
end
end
end
Run
masa@masa ~/ywesee/oddb.org/test/test_plugin $ ruby yaml.rb Loaded suite yaml Started . Finished in 0.000193 seconds. 1 tests, 1 assertions, 0 failures, 0 errors
Consideration
Commit
masa@masa ~/ywesee/oddb.org/test/test_plugin $ ruby yaml.rb Loaded suite yaml Started .. Finished in 0.00281 seconds.
2 tests, 3 assertions, 0 failures, 0 errors Result