diff --git a/app/controllers/field_test/experiments_controller.rb b/app/controllers/field_test/experiments_controller.rb index 861f4d7e4..46e256f59 100644 --- a/app/controllers/field_test/experiments_controller.rb +++ b/app/controllers/field_test/experiments_controller.rb @@ -12,5 +12,15 @@ module FieldTest rescue FieldTest::ExperimentNotFound raise ActionController::RoutingError, "Experiment not found" end + + def goal + @experiment = FieldTest::Experiment.find(params[:experiment_id]) + @goal = params.fetch(:goal) + unless @experiment.goals.include?(@goal) + raise ActionController::RoutingError, "Experiment's goal not found" + end + rescue FieldTest::ExperimentNotFound + raise ActionController::RoutingError, "Experiment not found" + end end end diff --git a/app/views/field_test/experiments/goal.html.erb b/app/views/field_test/experiments/goal.html.erb new file mode 100644 index 000000000..f7d4f7da7 --- /dev/null +++ b/app/views/field_test/experiments/goal.html.erb @@ -0,0 +1,52 @@ + +<% experiment = @experiment %> +

<%= experiment.name %><% unless experiment.active? %> Completed<% end %>

+<%# NOTE: The root_path is the Rails's engine root path, not the application's root path (e.g. "/") %> +

<%= link_to "Back to Experiments", FieldTest.railtie_routes_url_helpers.experiment_path(experiment.id) %>

+ +

<%= @goal.titleize %>

+<% results = experiment.results(goal: @goal) %> + + + + + + + + + + + + + <% results.each do |variant, result| %> + + + + + + + + <% end %> + +
VariantParticipantsConversionsConversion RateProb Winning
+ <%= variant %> + <% if variant == experiment.winner %> + + <% end %> + <%= result[:participated] %><%= result[:converted] %> + <% if result[:conversion_rate] %> + <%= (100.0 * result[:conversion_rate]).round(FieldTest.precision) %>% + <% else %> + - + <% end %> + + <% if result[:prob_winning] %> + <% if result[:prob_winning] < 0.01 %> + < 1% + <% else %> + <%= (100.0 * result[:prob_winning]).round(FieldTest.precision) %>% + <% end %> + <% end %> +
diff --git a/app/views/field_test/experiments/show.html.erb b/app/views/field_test/experiments/show.html.erb index ba60a5c18..efb1bd317 100644 --- a/app/views/field_test/experiments/show.html.erb +++ b/app/views/field_test/experiments/show.html.erb @@ -14,55 +14,14 @@ > Goals for <%= experiment.name %> - <% experiment.goals.each do |goal| %> - <% results = experiment.results(goal: goal) %> - - <% if experiment.multiple_goals? %> -

<%= goal.titleize %>

+ <% if experiment.id.start_with?("feed_strategy") %> diff --git a/config/routes/admin.rb b/config/routes/admin.rb index aa9de7c1b..37f9eea32 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -14,6 +14,7 @@ namespace :admin do mount Sidekiq::Web => "sidekiq" mount FieldTest::Engine, at: "abtests" + get "abtests/experiments/:experiment_id/:goal", to: "/field_test/experiments#goal" flipper_ui = Flipper::UI.app(Flipper, { rack_protection: { except: %i[authenticity_token form_token json_csrf