houdini_upgrade - correct the column headers for the copied and errors.csv
This commit is contained in:
parent
202a829134
commit
cf00c08ed0
1 changed files with 5 additions and 4 deletions
|
@ -107,12 +107,12 @@ RUBY
|
||||||
errors = results.select{|i| !i[:success]}.map{|i| i[:value]}
|
errors = results.select{|i| !i[:success]}.map{|i| i[:value]}
|
||||||
|
|
||||||
CSV.open("#{DateTime.now.utc.strftime('%Y%m%d%H%M%S')}_copied.csv", 'wb') do |csv|
|
CSV.open("#{DateTime.now.utc.strftime('%Y%m%d%H%M%S')}_copied.csv", 'wb') do |csv|
|
||||||
csv << ['Name', 'Id', "UploaderName", "FileToOpen", "CodeToRun"]
|
csv << ['Class Name', 'Id', "UploaderName", "FileToOpen"]
|
||||||
copied.each {|row| csv << row}
|
copied.each {|row| csv << row}
|
||||||
end
|
end
|
||||||
|
|
||||||
CSV.open("#{DateTime.now.utc.strftime('%Y%m%d%H%M%S')}_errored.csv", 'wb') do |csv|
|
CSV.open("#{DateTime.now.utc.strftime('%Y%m%d%H%M%S')}_errored.csv", 'wb') do |csv|
|
||||||
csv << ['Name', 'Id', "UploaderName", "Error"]
|
csv << ['Class Name', 'Id', "UploaderName", "FileToOpen", "Error"]
|
||||||
errors.each {|row| csv << row}
|
errors.each {|row| csv << row}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -121,6 +121,7 @@ RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
def process(**args)
|
def process(**args)
|
||||||
|
file_to_open = nil
|
||||||
begin
|
begin
|
||||||
if args[:upload_url]
|
if args[:upload_url]
|
||||||
filename = File.basename(URI.parse(args[:upload_url]).to_s)
|
filename = File.basename(URI.parse(args[:upload_url]).to_s)
|
||||||
|
@ -130,11 +131,11 @@ RUBY
|
||||||
attachment_relation = args[:record].send("#{args[:attachment_name].to_s}")
|
attachment_relation = args[:record].send("#{args[:attachment_name].to_s}")
|
||||||
attachment_relation.attach(io: open(file_to_open), filename: filename)
|
attachment_relation.attach(io: open(file_to_open), filename: filename)
|
||||||
end
|
end
|
||||||
return {success: true, value: [args[:record].id,args[:attachment_name],file_to_open]}
|
return {success: true, value: [args[:record].class.name, args[:record].id, args[:attachment_name],file_to_open]}
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
rescue => e
|
rescue => e
|
||||||
return {success: false, value: [ args[:record].id, args[:attachment_name], e]}
|
return {success: false, value: [args[:record].class.name, args[:record].id, args[:attachment_name], file_to_open, e]}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue