lib/daengine/teamsite_metadata_parser.rb in daengine-0.1.2 vs lib/daengine/teamsite_metadata_parser.rb in daengine-0.1.3
- old
+ new
@@ -38,10 +38,12 @@
def self.log(args)
@@logger.error(args) unless @@logger.blank?
end
def self.parse_tuple_file(file)
+ error_files = []
+ file_count = 0
time do
asset = nil
assets = {}
docpath = {}
valid = true
@@ -81,15 +83,22 @@
DigitalAsset.where(guid: key).delete_all
else
da = DigitalAsset.find_or_initialize_by(guid: key)
da.documents = []
da.update_attributes!(assets[key])
+ file_count = file_count + 1
end
rescue Exception => e
- p "Unable to save/update DigitalAsset guid=#{da.try(:guid)}, #{da.try(:errors).try(:full_messages)}"
+ error_files << "#{da.try(:guid)}, #{da.try(:errors).try(:full_messages)}"
end
end
+ log_txt = "TeamsiteMetadataParser: Failed to save/update following DigitalAssets in database:\n"
+ error_files.each do |asset_file|
+ log_txt = log_txt + "> #{asset_file}\n"
+ end
+ Daengine.log(log_txt, "warn")
DigitalAsset.purge! # if the purge criteria is met, purge anything not updated
+ Daengine.log("TeamsiteMetadataParser: #{file_count} records successfully added/updated", "info")
end
end
def self.time
start = Time.now