Sha256: 26b5c9a0d3161e7ff01df65bdff1e99bc7333c7236d2167814c14dc595f08d50

Contents?: true

Size: 995 Bytes

Versions: 25

Compression:

Stored size: 995 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Verifications
    module CsvCensus
      module Admin
        # A command with the business logic to create census data for a
        # organization.
        class CreateCensusData < Rectify::Command
          def initialize(form, organization)
            @form = form
            @organization = organization
          end

          # Executes the command. Broadcast this events:
          # - :ok when everything is valid
          # - :invalid when the form wasn't valid and couldn't proceed-
          #
          # Returns nothing.
          def call
            return broadcast(:invalid) unless @form.file

            # rubocop:disable Rails/SkipsModelValidations
            CsvDatum.insert_all(@organization, @form.data.values)
            # rubocop:enable Rails/SkipsModelValidations
            RemoveDuplicatesJob.perform_later(@organization)

            broadcast(:ok)
          end
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-verifications-0.26.10 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.26.9 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.26.8 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.26.7 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.26.5 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.26.4 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.26.3 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.26.2 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.26.1 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.26.0 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.26.0.rc2 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.26.0.rc1 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.25.2 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.25.1 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.25.0 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.25.0.rc4 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.25.0.rc3 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.25.0.rc2 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.25.0.rc1 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb
decidim-verifications-0.24.3 app/commands/decidim/verifications/csv_census/admin/create_census_data.rb