af83/chouette-core

View on GitHub
app/models/concerns/imports/without_referential_support.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Imports
  module WithoutReferentialSupport
    extend ActiveSupport::Concern

    # Overrides #import method to remove referential management
    def import
      Chouette::Benchmark.measure "import_#{import_type}", id: id do
        update status: 'running', started_at: Time.zone.now

        import_without_status

        self.status = 'successful' if status == 'running'
        self.ended_at = Time.zone.now
      end
    rescue StandardError => e
      update status: 'failed', ended_at: Time.zone.now
      Chouette::Safe.capture "#{self.class.name} ##{id} failed", e
    ensure
      save

      # Invoke the freaky logic /o\
      notify_parent
    end
  end
end