mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 13:35:21 +02:00
23 lines
606 B
Ruby
23 lines
606 B
Ruby
|
class FamilyDataExportJob < ApplicationJob
|
||
|
queue_as :default
|
||
|
|
||
|
def perform(family_export)
|
||
|
family_export.update!(status: :processing)
|
||
|
|
||
|
exporter = Family::DataExporter.new(family_export.family)
|
||
|
zip_file = exporter.generate_export
|
||
|
|
||
|
family_export.export_file.attach(
|
||
|
io: zip_file,
|
||
|
filename: family_export.filename,
|
||
|
content_type: "application/zip"
|
||
|
)
|
||
|
|
||
|
family_export.update!(status: :completed)
|
||
|
rescue => e
|
||
|
Rails.logger.error "Family export failed: #{e.message}"
|
||
|
Rails.logger.error e.backtrace.join("\n")
|
||
|
family_export.update!(status: :failed)
|
||
|
end
|
||
|
end
|