Class: Importo::ImportJobCallback
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- Importo::ImportJobCallback
- Includes:
- Sidekiq::Batch::Callback
- Defined in:
- app/importers/importo/import_job_callback.rb
Instance Method Summary collapse
- #complete_import(import) ⇒ Object
- #on_complete(status, options) ⇒ Object
- #perform(batch, params) ⇒ Object
Instance Method Details
#complete_import(import) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/importers/importo/import_job_callback.rb', line 11 def complete_import(import) if import.present? results_file = import.importer.results_file results_file = results_file.is_a?(StringIO) ? results_file : File.open(results_file) import.result.attach(io: results_file, filename: import.importer.file_name("results"), content_type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") ActiveRecord::Base.uncached do import. = 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 |
#on_complete(status, options) ⇒ Object
32 33 34 35 36 |
# File 'app/importers/importo/import_job_callback.rb', line 32 def on_complete(status, ) = .deep_stringify_keys import = Import.find(["import_id"]) complete_import(import) end |
#perform(batch, params) ⇒ Object
6 7 8 9 |
# File 'app/importers/importo/import_job_callback.rb', line 6 def perform(batch, params) import = Import.find(batch.properties[:import_id]) complete_import(import) end |