From 8969a13eb7872857cd81a4fa847677c226aa8a72 Mon Sep 17 00:00:00 2001 From: gebele Date: Wed, 11 Mar 2015 16:49:24 +0100 Subject: marked descriptor links;resize body if many models;fixed progress status --- application.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'application.rb') diff --git a/application.rb b/application.rb index 360db1d..3f3d5f0 100644 --- a/application.rb +++ b/application.rb @@ -10,6 +10,13 @@ helpers do @@models = [] models = `curl -k GET -H accept:text/uri-list #{$model[:uri]}`.split("\n") .collect{|m| model = OpenTox::Model::Lazar.find m; @@models << model if model.type.flatten.to_s =~ /PredictionModel/} + + class Numeric + def percent_of(n) + self.to_f / n.to_f * 100.0 + end + end + end get '/?' do @@ -232,7 +239,15 @@ post '/predict/?' do # predict with selected models # one prediction in 'pa' array = OpenTox::Dataset # all collected predictions in '@predictions' array + # add task for progressBar + total = @prediction_models.size + toptask = OpenTox::Task.find params[:task_uri] + toptask.metadata + toptask[RDF::OT.hasStatus] = "Running" + toptask[RDF::OT.percentageCompleted] = "10" + toptask.put @prediction_models.each_with_index do |m, idx| + idx = idx+1 # define type (classification|regression) m.type.join =~ /classification/i ? (@model_type << "classification") : (@model_type << "regression") @@ -244,6 +259,8 @@ post '/predict/?' do pa = [] pa << prediction @predictions << pa + toptask[RDF::OT.percentageCompleted] = idx.percent_of(total).round(1) + toptask.put end haml :prediction end -- cgit v1.2.3