lib/split/dashboard/views/_experiment.erb in split-2.2.0 vs lib/split/dashboard/views/_experiment.erb in split-3.0.0

- old
+ new

@@ -3,11 +3,30 @@ <% else %> <% experiment_class = "experiment" %> <% end %> <% experiment.calc_winning_alternatives %> +<% + extra_columns = [] + experiment.alternatives.each do |alternative| + extra_info = alternative.extra_info || {} + extra_columns += extra_info.keys + end + extra_columns.uniq! + summary_texts = {} + extra_columns.each do |column| + extra_infos = experiment.alternatives.map(&:extra_info).select{|extra_info| extra_info && extra_info[column] } + if extra_infos[0][column].kind_of?(Numeric) + summary_texts[column] = extra_infos.inject(0){|sum, extra_info| sum += extra_info[column]} + else + summary_texts[column] = "N/A" + end + end +%> + + <div class="<%= experiment_class %>" data-name="<%= experiment.name %>" data-complete="<%= experiment.has_winner? %>"> <div class="experiment-header"> <h2> Experiment: <%= experiment.name %> <% if experiment.version > 1 %><span class='version'>v<%= experiment.version %></span><% end %> @@ -30,10 +49,13 @@ <th>Alternative Name</th> <th>Participants</th> <th>Non-finished</th> <th>Completed</th> <th>Conversion Rate</th> + <% extra_columns.each do |column| %> + <th><%= column %></th> + <% end %> <th> <form> <select id="dropdown-<%=experiment.jstring(goal)%>" name="dropdown-<%=experiment.jstring(goal)%>"> <option value="confidence-<%=experiment.jstring(goal)%>">Confidence</option> <option value="probability-<%=experiment.jstring(goal)%>">Probability of being Winner</option> @@ -80,19 +102,22 @@ $('.box-<%=experiment.jstring(goal)%>').hide(); $('.' + $(this).val()).show(); }); }); </script> + <% extra_columns.each do |column| %> + <td><%= alternative.extra_info && alternative.extra_info[column] %></td> + <% end %> <td> <div class="box-<%=experiment.jstring(goal)%> confidence-<%=experiment.jstring(goal)%>"> <span title='z-score: <%= round(alternative.z_score(goal), 3) %>'><%= confidence_level(alternative.z_score(goal)) %></span> <br> </div> <div class="box-<%=experiment.jstring(goal)%> probability-<%=experiment.jstring(goal)%>"> <span title="p_winner: <%= round(alternative.p_winner(goal), 3) %>"><%= number_to_percentage(round(alternative.p_winner(goal), 3)) %>%</span> </div> - </td> + </td> <td> <% if experiment.has_winner? %> <% if experiment.winner.name == alternative.name %> Winner <% else %> @@ -116,9 +141,14 @@ <td>Totals</td> <td><%= total_participants %></td> <td><%= total_unfinished %></td> <td><%= total_completed %></td> <td>N/A</td> + <% extra_columns.each do |column| %> + <td> + <%= summary_texts[column] %> + </td> + <% end %> <td>N/A</td> <td>N/A</td> </tr> </table> </div>