Sha256: fe96f0347c5787295cda5e3cd2e6a5c841146098fdc83ec3566b482235cf58d5
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
module Importo class ImportJobCallback include Rails.application.routes.url_helpers def on_complete(_status, options) options = options.deep_stringify_keys import = Import.find(options["import_id"]) if import.present? results_file = import.importer.results_file if results_file.is_a?(StringIO) import.result.attach(io: results_file, filename: import.importer.file_name("results"), content_type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") else import.result.attach(io: File.open(results_file), filename: import.importer.file_name("results"), content_type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") end 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
4 entries across 4 versions & 1 rubygems