Skip to content

Commit

Permalink
make public method & fix syntax error when writing combined results
Browse files Browse the repository at this point in the history
  • Loading branch information
bkiahstroud committed Apr 5, 2024
1 parent 8a2a06f commit 7b94622
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions app/services/ams/missing_instantiations_locator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ def map_all_instantiation_identifiers
end
end

def merge_all_results
results_files = Dir.glob(WORKING_DIR.join('i16-AMS1Importer*.json'))
base_hash = JSON.parse(File.read(results_files.shift))
progressbar = ProgressBar.create(total: results_files.size, format: '%a %e %P% Processed: %c from %C')

results_files.each do |file|
merging_hash = JSON.parse(File.read(file))
base_hash.merge!(merging_hash) do |_inst_id, base_asset_ids, merging_asset_ids|
base_asset_ids | merging_asset_ids
end
progressbar.increment
end

File.open(WORKING_DIR.join('i16-combined-results.json'), 'w') do |file|
file.puts base_hash.to_json
end
end

private

def map_asset_id_to_inst_ids(xml_file)
Expand Down Expand Up @@ -92,23 +110,5 @@ def write_results
f.puts results.to_json
end
end

def merge_all_results
results_files = Dir.glob(WORKING_DIR.join('i16-AMS1Importer*.json'))
base_hash = JSON.parse(File.read(results_files.shift))
progressbar = ProgressBar.create(total: results_files.size, format: '%a %e %P% Processed: %c from %C')

results_files.each do |file|
merging_hash = JSON.parse(File.read(file))
base_hash.merge!(merging_hash) do |_inst_id, base_asset_id, merging_asset_id|
base_asset_id | merging_asset_id
end
progressbar.increment
end

File.open(WORKING_DIR.join('i16-combined-results.json', 'w')) do |file|
file.puts base_hash.to_json
end
end
end
end

0 comments on commit 7b94622

Please sign in to comment.