Skip to content

Commit

Permalink
add method to merge unique values of JSON results
Browse files Browse the repository at this point in the history
  • Loading branch information
bkiahstroud committed Apr 5, 2024
1 parent c27625b commit 8a2a06f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/services/ams/missing_instantiations_locator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,23 @@ 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 8a2a06f

Please sign in to comment.