Sha256: a71c3178e54686f4034044820de0edeb39495dbbbdd0e358f4ef19bfe52a5f96

Contents?: true

Size: 1.17 KB

Versions: 31

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module Census
      module Admin
        class CreateDatumJob < ApplicationJob
          queue_as :default

          def perform(user, dataset, csv_row)
            return if user.blank? || dataset.blank? || csv_row.blank?

            params = {
              document_number: csv_row[0],
              document_type: csv_row[1],
              birthdate: csv_row[2],
              full_name: csv_row[3],
              full_address: csv_row[4],
              postal_code: csv_row[5],
              mobile_phone_number: csv_row[6],
              email: csv_row[7],
              ballot_style_code: csv_row[8]
            }

            datum_form = DatumForm.from_params(params)
                                  .with_context(
                                    current_user: user,
                                    dataset: dataset
                                  )

            CreateDatum.call(datum_form, dataset)
          end

          after_perform do |job|
            Decidim::Votings::Census::Admin::IncrementDatasetProcessedRows.call(job.arguments.second)
          end
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
decidim-elections-0.27.9 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.27.8 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.27.7 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.27.6 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.26.10 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.26.9 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.27.5 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.26.8 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.27.4 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.27.3 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.26.7 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.26.5 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.27.2 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.27.1 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.26.4 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.27.0 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.26.3 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.27.0.rc2 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.27.0.rc1 app/jobs/decidim/votings/census/admin/create_datum_job.rb
decidim-elections-0.26.2 app/jobs/decidim/votings/census/admin/create_datum_job.rb