Class: Renalware::Feeds::Files::Practices::ImportJob

Inherits:
ApplicationJob
  • Object
show all
Includes:
Job, StringLogging
Defined in:
app/models/renalware/feeds/files/practices/import_job.rb

Constant Summary collapse

FILE_TO_EXTRACT_FROM_ARCHIVE =
/HSCOrgRefData_Full_/

Instance Method Summary collapse

Methods included from Job

#find_file_in, #formatted_exception, #log

Methods included from StringLogging

#logging_to_stringio

Instance Method Details

#perform(file) ⇒ Object

Arguments:

file - a Feeds::File object previously persisted.


25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/renalware/feeds/files/practices/import_job.rb', line 25

def perform(file)
  logging_to_stringio(strio = StringIO.new) # so we can write the error to the File model
  file.update!(status: :processing, attempts: file.attempts + 1)
  status = :success
  elapsed_ms = Benchmark.ms do
    process_archive(file.location)
  end
rescue StandardError => e
  Rails.logger.error(formatted_exception(e))
  status = :failure
  raise e
ensure
  file.update!(status: status, result: strio.string, time_taken: elapsed_ms)
end