Last active
February 14, 2024 00:28
-
-
Save orangewolf/908d94b2a1b13690390ec4e1fe6b9a3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f = Rails.root.join("tmp/imports/AMS1Importer_170000-180000/15-10wq0f0r.xml") | |
instantiation_identifier = nil | |
results = {} | |
# read each xml file | |
# get the physical_instantiation_local_identifiers and their matching cpb-aacip id | |
# get the digital_instantiation_local_identifiers and their matching cpb-aacip id | |
line = File.read(f) | |
pbcore_id = line.scan(/(cpb-aacip\/.+?)<\//).flatten.first | |
instantiation_identifiers = line.scan(/<instantiationIdentifier .+?>(.+?)<\/instantiationIdentifier>/mi).flatten | |
instantiation_identifiers.each do |instantiation_identifier| | |
results[instantiation_identifier] ||= [] | |
results[instantiation_identifier] << pbcore_id | |
end | |
end | |
# digital_instantiation = DigitalInstantiation.where(local_instantiation_identifier: xml_di[:local_instantiation_identifier]).first&.attributes&.symbolize_keys | |
di = digital_instantiations.select do |d| d.date_uploaded.to_datetime.strftime("%Y-%m-%d %H:%M") != d.date_modified.to_datetime.strftime("%Y-%m-%d %H:%M") end | |
results.each do |key, value| | |
digital_instantiations = DigitalInstantiation.where(local_instantiation_identifier: key) | |
# find any di that the created and updated times differ by more than a small margin | |
di = digital_instantiations.select do |d| d.date_uploaded.to_datetime.strftime("%Y-%m-%d %H:%M") != d.date_modified.to_datetime.strftime("%Y-%m-%d %H:%M") end | |
# add the asset id to the result set if so | |
results[key] << found['id'] | |
end | |
end | |
end | |
File.open('tmp/imports/child_snatcher.json', "w") do |f| | |
f.puts results.to_json | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment