Sha256: 32c5d61cee47aa349e0984b0406a447a5a8f1329337c5af79bcb400429cc974c

Contents?: true

Size: 833 Bytes

Versions: 1

Compression:

Stored size: 833 Bytes

Contents

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

    def on_complete(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

1 entries across 1 versions & 1 rubygems

Version Path
importo-3.0.15 app/importers/importo/import_job_callback.rb