Class: Tracebook::ExportsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tracebook/exports_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



5
6
7
8
# File 'app/controllers/tracebook/exports_controller.rb', line 5

def create
  blob = ExportJob.perform_now(format: params.fetch(:format, :csv), filters: export_filters)
  redirect_to export_path(blob.signed_id), notice: "Export ready"
end

#export_filtersObject (private)



19
20
21
# File 'app/controllers/tracebook/exports_controller.rb', line 19

def export_filters
  params.fetch(:filters, {}).permit(:provider, :model, :project, :status, :review_state, :from, :to)
end

#showObject



10
11
12
13
14
15
# File 'app/controllers/tracebook/exports_controller.rb', line 10

def show
  blob = ActiveStorage::Blob.find_signed(params[:id])
  send_data blob.download, filename: blob.filename.to_s, type: blob.content_type
rescue ActiveSupport::MessageVerifier::InvalidSignature
  head :not_found
end