Class: Renalware::UKRDC::Incoming::ImportSurveys
- Inherits:
-
Object
- Object
- Renalware::UKRDC::Incoming::ImportSurveys
- Defined in:
- app/models/renalware/ukrdc/incoming/import_surveys.rb
Instance Attribute Summary collapse
-
#batch_uuid ⇒ Object
readonly
Returns the value of attribute batch_uuid.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(paths: nil, logger: nil) ⇒ ImportSurveys
constructor
A new instance of ImportSurveys.
Constructor Details
#initialize(paths: nil, logger: nil) ⇒ ImportSurveys
Returns a new instance of ImportSurveys.
13 14 15 16 17 |
# File 'app/models/renalware/ukrdc/incoming/import_surveys.rb', line 13 def initialize(paths: nil, logger: nil) @paths = paths || Renalware::UKRDC::Incoming::Paths.new @logger = logger || Rails.logger @batch_uuid = SecureRandom.uuid # to group logging output end |
Instance Attribute Details
#batch_uuid ⇒ Object (readonly)
Returns the value of attribute batch_uuid.
11 12 13 |
# File 'app/models/renalware/ukrdc/incoming/import_surveys.rb', line 11 def batch_uuid @batch_uuid end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/renalware/ukrdc/incoming/import_surveys.rb', line 19 def call Incoming::FileList.new(paths: paths).each_file do |filepath| if already_imported?(filepath) logger.info "Skipping: #{filepath} already successfully imported" FileUtils.mv filepath, paths.archive.join(filepath.basename) next end logger.info "Processing: #{filepath}" import_surveys_from_file(filepath) end rescue StandardError => e Renalware::Engine.exception_notifier.notify(e) raise e end |