Class: Decidim::Proposals::ExportJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
decidim-proposals/app/jobs/decidim/proposals/export_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(user, feature, format) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'decidim-proposals/app/jobs/decidim/proposals/export_job.rb', line 7

def perform(user, feature, format)
  proposals = Proposal
              .where(feature: feature)
              .includes(:category, feature: { participatory_process: :organization })

  export_data = Decidim::Exporters.const_get(format.upcase)
                                  .new(proposals, ProposalSerializer).export

  name = "proposals-#{I18n.localize(DateTime.now.to_date, format: :default)}-#{Time.now.seconds_since_midnight.to_i}"

  ExportMailer.export(user, name, export_data).deliver_now
end