Sha256: 3bde39667ae769d66be75add3a60eeab4d0a6d4a8a07e9712d6bf680c0f1fa76
Contents?: true
Size: 1.9 KB
Versions: 3
Compression:
Stored size: 1.9 KB
Contents
require 'sinatra/base' require 'split' require 'bigdecimal' module Split class Dashboard < Sinatra::Base dir = File.dirname(File.expand_path(__FILE__)) set :views, "#{dir}/dashboard/views" set :public_folder, "#{dir}/dashboard/public" set :static, true set :method_override, true helpers do def url(*path_parts) [ path_prefix, path_parts ].join("/").squeeze('/') end def path_prefix request.env['SCRIPT_NAME'] end def number_to_percentage(number, precision = 2) round(number * 100) end def round(number, precision = 2) BigDecimal.new(number.to_s).round(precision).to_f end def confidence_level(z_score) z = z_score.to_f if z > 0.0 if z < 1.96 'no confidence' elsif z < 2.57 '95% confidence' elsif z < 3.29 '99% confidence' else '99.9% confidence' end elsif z < 0.0 if z > -1.96 'no confidence' elsif z > -2.57 '95% confidence' elsif z > -3.29 '99% confidence' else '99.9% confidence' end else "No Change" end end end get '/' do @experiments = Split::Experiment.all erb :index end post '/:experiment' do @experiment = Split::Experiment.find(params[:experiment]) @alternative = Split::Alternative.new(params[:alternative], params[:experiment]) @experiment.winner = @alternative.name redirect url('/') end post '/reset/:experiment' do @experiment = Split::Experiment.find(params[:experiment]) @experiment.reset redirect url('/') end delete '/:experiment' do @experiment = Split::Experiment.find(params[:experiment]) @experiment.delete redirect url('/') end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
split-0.3.3 | lib/split/dashboard.rb |
split-0.3.2 | lib/split/dashboard.rb |
split-0.3.1 | lib/split/dashboard.rb |