Sha256: d0d9a6b5ca3229f764ea0dbb358e6d7d3c001b5031d9038e1baa4be5b8eb951b

Contents?: true

Size: 796 Bytes

Versions: 21

Compression:

Stored size: 796 Bytes

Contents

# frozen_string_literal: true

module Decidim
  class DataPortabilityExportJob < ApplicationJob
    queue_as :default

    def perform(user, format)
      objects = Decidim::DataPortabilitySerializers.data_entities
      export_data = []
      export_images = []

      objects.each do |object|
        klass = Object.const_get(object)
        export_data << [klass.model_name.name.parameterize.pluralize, Decidim::Exporters.find_exporter(format).new(klass.user_collection(user), klass.export_serializer).export]
        export_images << [klass.model_name.name.parameterize.pluralize, klass.data_portability_images(user).flatten] unless klass.data_portability_images(user).nil?
      end

      ExportMailer.data_portability_export(user, export_data, export_images).deliver_now
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
decidim-core-0.13.0.pre1 app/jobs/decidim/data_portability_export_job.rb