summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2018-04-23 14:20:10 +0000
committergebele <gebele@in-silico.ch>2018-04-23 14:20:10 +0000
commit8a940a694366214164bcdb853388bc41ccbf4522 (patch)
treeef9e3ad24f2a5550e63c452eae665da75cd1a83f
parentde849d5b6cc553cc6969dd6b9b486b808ac89f3d (diff)
fixed file ending on download
-rw-r--r--application.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/application.rb b/application.rb
index 38ac934..edff1c9 100644
--- a/application.rb
+++ b/application.rb
@@ -141,7 +141,7 @@ end
get '/download/dataset/:id' do
response['Content-Type'] = "text/csv"
- dataset = Dataset.find params[:id]
+ dataset = Batch.find params[:id]
tempfile = Tempfile.new
tempfile.write(File.read("tmp/"+dataset.name+".csv"))
tempfile.rewind
@@ -157,9 +157,10 @@ end
get '/predict/csv/:task/:model/:filename/?' do
response['Content-Type'] = "text/csv"
+ filename = params[:filename] =~ /\.csv$/ ? params[:filename].gsub(/\.csv$/,"") : params[:filename]
task = Task.find params[:task].to_s
m = Model::Validation.find params[:model].to_s unless params[:model] == "Cramer"
- dataset = Batch.find_by(:name => params[:filename])
+ dataset = Batch.find_by(:name => filename)
warnings = dataset.warnings.blank? ? nil : dataset.warnings.join("\n")
unless warnings.nil?
keys_array = []
@@ -219,7 +220,7 @@ get '/predict/csv/:task/:model/:filename/?' do
tempfile.write(csv)
end
tempfile.rewind
- send_file tempfile, :filename => "#{Time.now.strftime("%Y-%m-%d")}_lazar_batch_prediction_#{endpoint}_#{params[:filename]}.csv", :type => "text/csv", :disposition => "attachment"
+ send_file tempfile, :filename => "#{Time.now.strftime("%Y-%m-%d")}_lazar_batch_prediction_#{endpoint}_#{filename}.csv", :type => "text/csv", :disposition => "attachment"
end
post '/predict/?' do