From 520615945ff0b4068c2a5a222a097cb97f890a4a Mon Sep 17 00:00:00 2001 From: lfarrell Date: Wed, 26 May 2021 10:12:53 -0400 Subject: [PATCH] Allow multiple metadata spreadsheets --- .../tasks/onescience_ingest_service.rb | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/services/tasks/onescience_ingest_service.rb b/app/services/tasks/onescience_ingest_service.rb index a3e1eb611..93feb0998 100644 --- a/app/services/tasks/onescience_ingest_service.rb +++ b/app/services/tasks/onescience_ingest_service.rb @@ -211,16 +211,19 @@ def load_data puts "[#{Time.now}] loaded embargo mappings" # read from xlsx in projects folder - workbook = Roo::Spreadsheet.open(File.join(@config['metadata_dir'], @config['metadata_file'])) - sheets = workbook.sheets @data = [] - sheets.each do |sheet| - if sheet.match('1foldr_UNCCH_01_Part') - data_hash = workbook.sheet(sheet).parse(headers: true) - data_hash.delete_if{|hash| hash['onescience_id'].blank? } - # first hash is of headers - data_hash.delete_at(0) - @data << data_hash + Array.wrap(@config['metadata_file']).each do|metadata_file| + workbook = Roo::Spreadsheet.open(File.join(@config['metadata_dir'], metadata_file)) + sheets = workbook.sheets + + sheets.each do |sheet| + if sheet.match('1foldr_UNCCH_01_Part') + data_hash = workbook.sheet(sheet).parse(headers: true) + data_hash.delete_if{|hash| hash['onescience_id'].blank? } + # first hash is of headers + data_hash.delete_at(0) + @data << data_hash + end end end @data.flatten!