Class: Decidim::OpenDataJob

Inherits:
ApplicationJob show all
Defined in:
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
# File '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 "Couldn't generate Open Data export" unless exporter.export.positive?

  organization.open_data_file.attach(io: File.open(path, "rb"), filename: organization.open_data_file_path)
end