Class: Decidim::OpenDataJob

Inherits:
ApplicationJob show all
Defined in:
decidim-core/app/jobs/decidim/open_data_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(organization) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'decidim-core/app/jobs/decidim/open_data_job.rb', line 7

def perform(organization)
  path = Rails.root.join("tmp/#{organization.open_data_file_path}")

  exporter = OpenDataExporter.new(organization, path)
  raise "Could not generate Open Data export" unless exporter.export.positive?

  organization.open_data_file.attach(io: File.open(path, "rb"), filename: organization.open_data_file_path)
  # Deletes the temporary file file
  File.delete(path)
end