Class: Decidim::ActionDelegator::Admin::ImportCsvJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/decidim/action_delegator/admin/import_csv_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(importer_type, csv_file, current_user, current_setting) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/jobs/decidim/action_delegator/admin/import_csv_job.rb', line 9

def perform(importer_type, csv_file, current_user, current_setting)
  importer = if importer_type == "DelegationsCsvImporter"
               Decidim::ActionDelegator::DelegationsCsvImporter.new(csv_file, current_user, current_setting)
             else
               Decidim::ActionDelegator::ParticipantsCsvImporter.new(csv_file, current_user, current_setting)
             end

  import_summary = importer.import!

  Decidim::ActionDelegator::ImportMailer
    .import(current_user, import_summary, import_summary[:details_csv_path])
    .deliver_later

  import_summary
end