bandit 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -35,7 +35,7 @@ For instance, in a link:
35
35
 
36
36
  <%= link_to "new purchase", new_purchase_path, :style => "font-size: #{bandit_choose(:click_test)}px;" %>
37
37
 
38
- You can force a particular alternative by adding a query parameter named "bandit_<expname>" and setting it's value to the alternative you want. For instance, given the above experiment in the configuration example:
38
+ You can force a particular alternative by adding a query parameter named "bandit_<experiment name>" and setting it's value to the alternative you want. For instance, given the above experiment in the configuration example:
39
39
 
40
40
  http://<yourhost>/<path>?bandit_click_test=40
41
41
 
@@ -52,7 +52,7 @@ To track a conversion in your controller:
52
52
 
53
53
  Then, add the following to your config/routes.rb file:
54
54
 
55
- match 'bandit' => 'bandit#index'
55
+ resources :bandit
56
56
 
57
57
  To see a dashboard with relevant information, go to:
58
58
 
@@ -61,7 +61,9 @@ To see a dashboard with relevant information, go to:
61
61
  = Tests
62
62
  To run tests:
63
63
 
64
- rake test
64
+ rake test_memory
65
+ rake test_memcache
66
+ rake test_redis
65
67
 
66
68
  To produce fake data for the past week, first create an experiment definition. Then, run the following rake task:
67
69
 
@@ -1,3 +1,3 @@
1
1
  module Bandit
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -17,7 +17,9 @@ class BanditController < ApplicationController
17
17
  def experiment_csv(experiment)
18
18
  rows = []
19
19
  experiment.alternatives.each { |alt|
20
- experiment.alternative_start(alt).date.upto(Date.today) { |d|
20
+ start = experiment.alternative_start(alt)
21
+ next if start.nil?
22
+ start.date.upto(Date.today) { |d|
21
23
  pcount = Bandit::DateHour.date_inject(d, 0) { |sum,dh| sum + experiment.participant_count(alt, dh) }
22
24
  ccount = Bandit::DateHour.date_inject(d, 0) { |sum,dh| sum + experiment.conversion_count(alt, dh) }
23
25
  rows << [ alt, d.year, d.month, d.day, pcount, ccount ].join("\t")
@@ -19,4 +19,10 @@ nav ul li a { display: block; padding: 0 30px 0 0; text-deco
19
19
 
20
20
  /* FOOTER
21
21
  ---------------------------- */
22
- footer { border-top: 3px solid #f1f1f1; padding: 15px 0; margin-top: 20px; }
22
+ footer { border-top: 3px solid #f1f1f1; padding: 15px 0; margin-top: 20px; }
23
+
24
+ table { margin-top: 30px; margin-bottom: 30px; }
25
+
26
+ .graph { margin-top: 20px; }
27
+
28
+ table { padding-left: 30px; }
@@ -3,6 +3,10 @@ module BanditHelper
3
3
  Bandit.config.storage.titleize
4
4
  end
5
5
 
6
+ def round_percent(percent)
7
+ (percent * 100).round / 100.0
8
+ end
9
+
6
10
  def player_name
7
11
  Bandit.config.player.titleize
8
12
  end
@@ -4,31 +4,48 @@ function show_chart(title, url) {
4
4
 
5
5
  function show_chart_data(title, data) {
6
6
  var options = {
7
- chart: { renderTo: 'gcontainer' },
7
+ chart: { renderTo: 'totals_gcontainer' },
8
8
  title: { text: title },
9
9
  rangeSelector: { selected: 1 },
10
- subtitle: { text: "conversions" },
11
- yAxis: { title: { text: "participants" } },
10
+ subtitle: { text: "participant / conversion totals" },
11
+ yAxis: { title: { text: "people" } },
12
+ series: []
13
+ };
14
+
15
+ var percent_options = {
16
+ chart: { renderTo: 'percents_gcontainer' },
17
+ title: { text: title },
18
+ rangeSelector: { selected: 1 },
19
+ subtitle: { text: "conversion percents" },
20
+ yAxis: { title: { text: "% converted" } },
12
21
  series: []
13
22
  };
14
23
 
15
24
  var series_c = null;
16
25
  var series_p = null;
26
+ var series_percent = null;
17
27
  $.each(data.split('\n'), function(lineNo, line) {
18
28
  var items = line.split("\t");
19
29
  var ctitle = items[0] + " conversions";
20
30
  var ptitle = items[0] + " participants";
31
+ var percent_title = items[0] + " conversion %";
21
32
  if(series_c == null || series_c.name != ctitle) {
22
- if(series_c != null) { options.series.push(series_p); options.series.push(series_c); }
33
+ if(series_c != null) { options.series.push(series_p); options.series.push(series_c); percent_options.series.push(series_percent); }
23
34
  series_c = { data: [], name: ctitle };
24
35
  series_p = { data: [], name: ptitle };
36
+ series_percent = { data: [], name: percent_title, yDecimals: 2 };
25
37
  }
26
38
  var date = Date.UTC(parseInt(items[1]), parseInt(items[2]), parseInt(items[3]));
27
- var value = parseFloat(items[4]);
28
- series_p.data.push([date, parseFloat(items[4])]);
29
- series_c.data.push([date, parseFloat(items[5])]);
39
+ var participants = parseFloat(items[4]);
40
+ var conversions = parseFloat(items[5]);
41
+ var conversion_percent = Math.round((conversions / participants) * 100) / 100;
42
+ series_p.data.push([date, participants]);
43
+ series_c.data.push([date, conversions]);
44
+ series_percent.data.push([date, conversion_percent]);
30
45
  });
31
46
  options.series.push(series_p);
32
47
  options.series.push(series_c);
48
+ percent_options.series.push(series_percent);
33
49
  var chart = new Highcharts.StockChart(options);
50
+ var charttwo = new Highcharts.StockChart(percent_options);
34
51
  }
@@ -0,0 +1,19 @@
1
+ <table cellspacing="0">
2
+ <tbody>
3
+ <tr>
4
+ <th scope="col" class="name">Alternative</th>
5
+ <th scope="col">Participants</th>
6
+ <th scope="col">Conversions</th>
7
+ <th scope="col">Conversion Rate</th>
8
+ </tr>
9
+
10
+ <% experiment.alternatives.each_with_index { |alt, index| %>
11
+ <tr<%= (index % 2 == 0) ? '' : ' class="alt"'.html_safe %>>
12
+ <td class="name"><%= alt %></td>
13
+ <td><%= experiment.participant_count(alt) %></td>
14
+ <td><%= experiment.conversion_count(alt) %></td>
15
+ <td><%= round_percent experiment.conversion_rate(alt) %> %</td>
16
+ </tr>
17
+ <% } %>
18
+ </tbody>
19
+ </table>
@@ -9,13 +9,6 @@
9
9
  <p>
10
10
  <%= experiment.description %>
11
11
  </p>
12
- <% experiment.alternatives.each { |alt| %>
13
- <h3>Alternative: <%= alt %></h3>
14
- <ul>
15
- <li>Participants: <%= experiment.participant_count(alt) %></li>
16
- <li>Conversions: <%= experiment.conversion_count(alt) %></li>
17
- <li>Conversion rate: <%= experiment.conversion_rate(alt) %> %</li>
18
- </ul>
19
- <% } %>
12
+ <%= render :partial => 'experiment_table', :locals => { :experiment => experiment } %>
20
13
  <% } %>
21
14
  </section>
@@ -4,16 +4,11 @@
4
4
  <%= @experiment.description %>
5
5
  </p>
6
6
 
7
- <div id="gcontainer"></div>
7
+ <%= render :partial => 'experiment_table', :locals => { :experiment => @experiment } %>
8
8
 
9
- <% @experiment.alternatives.each { |alt| %>
10
- <h2>Alternative: <%= alt %></h2>
11
- <ul>
12
- <li>Participants: <%= @experiment.participant_count(alt) %></li>
13
- <li>Conversions: <%= @experiment.conversion_count(alt) %></li>
14
- <li>Conversion rate: <%= @experiment.conversion_rate(alt) %> %</li>
15
- </ul>
16
- <% } %>
9
+ <div id="totals_gcontainer" class="graph"></div>
10
+
11
+ <div id="percents_gcontainer" class="graph"></div>
17
12
 
18
13
  </section>
19
14
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bandit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Muller
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-06 01:00:00 -04:00
18
+ date: 2011-11-12 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -119,6 +119,7 @@ files:
119
119
  - lib/generators/bandit/templates/dashboard/js/bandit.js
120
120
  - lib/generators/bandit/templates/dashboard/js/highstock.js
121
121
  - lib/generators/bandit/templates/dashboard/js/jquery.min.js
122
+ - lib/generators/bandit/templates/dashboard/view/_experiment_table.html.erb
122
123
  - lib/generators/bandit/templates/dashboard/view/index.html.erb
123
124
  - lib/generators/bandit/templates/dashboard/view/show.html.erb
124
125
  - players.rdoc