Sha256: 2adc6078b263185f717cfc4d3dbce3cb883a1bb7764e6503d3ab13c8c136f0df

Contents?: true

Size: 841 Bytes

Versions: 2

Compression:

Stored size: 841 Bytes

Contents

module Importo
  class ImportJobCallback
    include Rails.application.routes.url_helpers

    def on_success(_status, options)
      options = options.deep_stringify_keys
      import = Import.find(options["import_id"])
      if import.present?
        import.result.attach(io: import.importer.results_file, filename: import.importer.file_name("results"),
          content_type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")

        ActiveRecord::Base.uncached do
          import.result_message = I18n.t("importo.importers.result_message",
            nr: import.results.where("details @> ?", {state: "success"}.to_json).count, of: import.importer.send(:row_count))
        end

        if import.can_complete?
          import.complete!
        else
          import.save!
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
importo-3.0.17 app/importers/importo/import_job_callback.rb
importo-3.0.16 app/importers/importo/import_job_callback.rb