Sha256: e5c552d980246a56c83c2039010fd86e765232567af0bd31fddb73693f16a137

Contents?: true

Size: 800 Bytes

Versions: 13

Compression:

Stored size: 800 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Initiatives
    class ExportInitiativesJob < ApplicationJob
      queue_as :exports

      def perform(user, organization, format, collection_ids = nil)
        export_data = Decidim::Exporters.find_exporter(format).new(
          collection_to_export(collection_ids, organization),
          serializer
        ).export

        ExportMailer.export(user, "initiatives", export_data).deliver_now
      end

      private

      def collection_to_export(ids, organization)
        collection = Decidim::Initiative.where(organization:)

        collection = collection.where(id: ids) if ids.present?

        collection.order(id: :asc)
      end

      def serializer
        Decidim::Initiatives::InitiativeSerializer
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
decidim-initiatives-0.29.1 app/jobs/decidim/initiatives/export_initiatives_job.rb
decidim-initiatives-0.28.4 app/jobs/decidim/initiatives/export_initiatives_job.rb
decidim-initiatives-0.29.0 app/jobs/decidim/initiatives/export_initiatives_job.rb
decidim-initiatives-0.28.3 app/jobs/decidim/initiatives/export_initiatives_job.rb
decidim-initiatives-0.29.0.rc4 app/jobs/decidim/initiatives/export_initiatives_job.rb
decidim-initiatives-0.29.0.rc3 app/jobs/decidim/initiatives/export_initiatives_job.rb
decidim-initiatives-0.29.0.rc2 app/jobs/decidim/initiatives/export_initiatives_job.rb
decidim-initiatives-0.29.0.rc1 app/jobs/decidim/initiatives/export_initiatives_job.rb
decidim-initiatives-0.28.2 app/jobs/decidim/initiatives/export_initiatives_job.rb
decidim-initiatives-0.28.1 app/jobs/decidim/initiatives/export_initiatives_job.rb
decidim-initiatives-0.28.0 app/jobs/decidim/initiatives/export_initiatives_job.rb
decidim-initiatives-0.28.0.rc5 app/jobs/decidim/initiatives/export_initiatives_job.rb
decidim-initiatives-0.28.0.rc4 app/jobs/decidim/initiatives/export_initiatives_job.rb