trailguide 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/trail_guide/admin/application.js +0 -2
- data/app/controllers/trail_guide/admin/experiments_controller.rb +36 -1
- data/app/views/layouts/trail_guide/admin/application.html.erb +11 -5
- data/app/views/trail_guide/admin/experiments/_experiment.html.erb +74 -0
- data/app/views/trail_guide/admin/experiments/index.html.erb +13 -1
- data/config/admin/routes.rb +9 -1
- data/lib/trail_guide/adapters/participants/unity.rb +3 -1
- data/lib/trail_guide/experiment.rb +1 -1
- data/lib/trail_guide/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1168244069ee4cc060d0e55a08c80bbccff498fa545105604902acc15a750386
|
4
|
+
data.tar.gz: b84fd9db3485005545dae5c0a8d52d5b30b85eb6bd09da83c690db85adb179d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 203c6d29fe77bc8e5ef5f4ffbe11f93bbc14c9d8923228285c4fe03c03f59b16c2a1aebcf617443fcc21b420cd51d8dbfe77ac8b983a430a3a1f6b0ec0f386a8
|
7
|
+
data.tar.gz: 9508e5301cc1b3dc9aef23e2fe0199b50f2ea29bdc704662de63f002bec1adade251111afbf2e374410f0dd33a69f5bc8509a1a2d334095c2d67ca25a049885d
|
@@ -1,8 +1,43 @@
|
|
1
1
|
module TrailGuide
|
2
2
|
module Admin
|
3
|
-
class ExperimentsController < ApplicationController
|
3
|
+
class ExperimentsController < TrailGuide::Admin::ApplicationController
|
4
|
+
before_action except: [:index] do
|
5
|
+
(redirect_to :back rescue redirect_to trail_guide_admin.experiments_path) and return unless experiment.present?
|
6
|
+
end
|
7
|
+
|
4
8
|
def index
|
5
9
|
end
|
10
|
+
|
11
|
+
def start
|
12
|
+
experiment.start!
|
13
|
+
redirect_to :back rescue redirect_to trail_guide_admin.experiments_path
|
14
|
+
end
|
15
|
+
|
16
|
+
def stop
|
17
|
+
experiment.stop!
|
18
|
+
redirect_to :back rescue redirect_to trail_guide_admin.experiments_path
|
19
|
+
end
|
20
|
+
|
21
|
+
def reset
|
22
|
+
experiment.reset!
|
23
|
+
redirect_to :back rescue redirect_to trail_guide_admin.experiments_path
|
24
|
+
end
|
25
|
+
|
26
|
+
def restart
|
27
|
+
experiment.reset! && experiment.start!
|
28
|
+
redirect_to :back rescue redirect_to trail_guide_admin.experiments_path
|
29
|
+
end
|
30
|
+
|
31
|
+
def winner
|
32
|
+
experiment.declare_winner!(params[:winner])
|
33
|
+
redirect_to :back rescue redirect_to trail_guide_admin.experiments_path
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def experiment
|
39
|
+
@experiment ||= TrailGuide.catalog.find(params[:id])
|
40
|
+
end
|
6
41
|
end
|
7
42
|
end
|
8
43
|
end
|
@@ -1,16 +1,22 @@
|
|
1
|
-
<!
|
2
|
-
<html>
|
1
|
+
<!doctype html>
|
2
|
+
<html lang="en">
|
3
3
|
<head>
|
4
4
|
<title>TrailGuide Admin</title>
|
5
5
|
<%= csrf_meta_tags %>
|
6
|
-
<%= csp_meta_tag %>
|
7
6
|
|
7
|
+
<meta charset="utf-8">
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
8
11
|
<%= stylesheet_link_tag "trail_guide/admin/application", media: "all" %>
|
9
|
-
<%= javascript_include_tag "trail_guide/admin/application" %>
|
10
12
|
</head>
|
11
13
|
<body>
|
12
14
|
|
13
|
-
<%= yield %>
|
15
|
+
<%= yield %>
|
14
16
|
|
17
|
+
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
18
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
19
|
+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
20
|
+
<%= javascript_include_tag "trail_guide/admin/application" %>
|
15
21
|
</body>
|
16
22
|
</html>
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<div class="row justify-content-center">
|
2
|
+
<div class="col-sm-12 col-md-10 col-lg-8">
|
3
|
+
<h3><%= experiment.experiment_name.to_s.humanize.titleize %></h3>
|
4
|
+
|
5
|
+
<table class="table table-striped table-hover">
|
6
|
+
<thead>
|
7
|
+
<tr>
|
8
|
+
<td>
|
9
|
+
<% if experiment.started? %>
|
10
|
+
<%= link_to "stop", trail_guide_admin.stop_experiment_path(experiment.experiment_name), class: 'btn btn-sm btn-warning', method: :put %>
|
11
|
+
<%= link_to "restart", trail_guide_admin.restart_experiment_path(experiment.experiment_name), class: 'btn btn-sm btn-danger',method: :put %>
|
12
|
+
<% else %>
|
13
|
+
<%= link_to "start", trail_guide_admin.start_experiment_path(experiment.experiment_name), class: 'btn btn-sm btn-success',method: :put %>
|
14
|
+
<% end %>
|
15
|
+
<%= link_to "reset", trail_guide_admin.reset_experiment_path(experiment.experiment_name), class: 'btn btn-sm btn-danger',method: :put %>
|
16
|
+
</td>
|
17
|
+
|
18
|
+
<th scope="col">Participants</th>
|
19
|
+
|
20
|
+
<% if experiment.goals.empty? %>
|
21
|
+
<th scope="col">Converted</th>
|
22
|
+
<% else %>
|
23
|
+
<% experiment.goals.each do |goal| %>
|
24
|
+
<th scope="col"><%= goal.to_s.humanize.titleize %></th>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
<th> </th>
|
29
|
+
</tr>
|
30
|
+
</thead>
|
31
|
+
|
32
|
+
<tbody>
|
33
|
+
<% experiment.variants.each do |variant| %>
|
34
|
+
<tr>
|
35
|
+
<th scope="row"><%= variant.name.to_s.humanize.titleize %></th>
|
36
|
+
|
37
|
+
<td><%= variant.participants %></td>
|
38
|
+
|
39
|
+
<% if experiment.goals.empty? %>
|
40
|
+
<td><%= variant.converted %></td>
|
41
|
+
<% else %>
|
42
|
+
<% experiment.goals.each do |goal| %>
|
43
|
+
<td><%= variant.converted(goal) %></td>
|
44
|
+
<% end %>
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
<td>
|
48
|
+
<% if experiment.winner? && variant == experiment.winner %>
|
49
|
+
<span class="badge badge-primary">winner</span>
|
50
|
+
<% else %>
|
51
|
+
<%= link_to "use this", trail_guide_admin.winner_experiment_path(experiment.experiment_name, variant.name), class: 'btn btn-sm btn-secondary', method: :put %>
|
52
|
+
<% end %>
|
53
|
+
</td>
|
54
|
+
</tr>
|
55
|
+
<% end %>
|
56
|
+
</tbody>
|
57
|
+
|
58
|
+
<tfoot>
|
59
|
+
<tr class="table-secondary">
|
60
|
+
<th scope="row"> </th>
|
61
|
+
<td><%= experiment.variants.sum(&:participants) %></td>
|
62
|
+
<% if experiment.goals.empty? %>
|
63
|
+
<td><%= experiment.variants.sum(&:converted) %></td>
|
64
|
+
<% else %>
|
65
|
+
<% experiment.goals.each do |goal| %>
|
66
|
+
<td><%= experiment.variants.sum { |var| var.converted(goal) } %></td>
|
67
|
+
<% end %>
|
68
|
+
<% end %>
|
69
|
+
<td> </td>
|
70
|
+
</tr>
|
71
|
+
</tfoot>
|
72
|
+
</table>
|
73
|
+
</div>
|
74
|
+
</div>
|
@@ -1 +1,13 @@
|
|
1
|
-
<
|
1
|
+
<div class="container-fluid">
|
2
|
+
<div class="row justify-content-center">
|
3
|
+
<div class="col-sm-12 col-md-10 col-lg-8">
|
4
|
+
<h1>Experiments</h1>
|
5
|
+
</div>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<hr />
|
9
|
+
|
10
|
+
<% TrailGuide.catalog.each do |experiment| %>
|
11
|
+
<%= render 'experiment', experiment: experiment %>
|
12
|
+
<% end %>
|
13
|
+
</div>
|
data/config/admin/routes.rb
CHANGED
@@ -1,3 +1,11 @@
|
|
1
1
|
TrailGuide::Admin::Engine.routes.draw do
|
2
|
-
resources :experiments, only: [:index]
|
2
|
+
resources :experiments, path: '/', only: [:index] do
|
3
|
+
member do
|
4
|
+
match :start, via: [:put, :post, :get]
|
5
|
+
match :stop, via: [:put, :post, :get]
|
6
|
+
match :reset, via: [:put, :post, :get]
|
7
|
+
match :restart, via: [:put, :post, :get]
|
8
|
+
match 'winner/:winner', action: :winner, as: :winner, via: [:put, :post, :get]
|
9
|
+
end
|
10
|
+
end
|
3
11
|
end
|
@@ -89,7 +89,9 @@ module TrailGuide
|
|
89
89
|
|
90
90
|
def logged_out_context?
|
91
91
|
return false unless configuration.visitor_cookie.present?
|
92
|
-
context.
|
92
|
+
context.send(:cookies)[configuration.visitor_cookie].present?
|
93
|
+
rescue => e
|
94
|
+
return false
|
93
95
|
end
|
94
96
|
|
95
97
|
def user_context?
|
data/lib/trail_guide/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailguide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rebec
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- app/controllers/trail_guide/admin/experiments_controller.rb
|
111
111
|
- app/controllers/trail_guide/application_controller.rb
|
112
112
|
- app/views/layouts/trail_guide/admin/application.html.erb
|
113
|
+
- app/views/trail_guide/admin/experiments/_experiment.html.erb
|
113
114
|
- app/views/trail_guide/admin/experiments/index.html.erb
|
114
115
|
- config/admin/routes.rb
|
115
116
|
- config/routes.rb
|