trailguide 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c099d61bcdf95cc843e70c0f6d29181e98a0b406223c9da34f58c5acbc512275
4
- data.tar.gz: 86d169432b3f218fd174b52b0b1bb8e16134dbfbac3e4d8b16064f5b077e1926
3
+ metadata.gz: e93ca2d83d4cdd34db5aabbf756d177659c1adaad045dbcf9b80bb0511c36b6e
4
+ data.tar.gz: ffcf53c636b650b2ab578d69078df41b13f828a48c72feb5eebcbd79b221f5a6
5
5
  SHA512:
6
- metadata.gz: c6ded8b6d09c96fa94238274675b4450163cd71d83a6c8275d590a2dede66435b5e89aacf95afc91d78f1a04a26dae4763a78c432455b9d9de3e015433760458
7
- data.tar.gz: 1819ff2788259221bdd5e4942df7d3b5f99320b3dc2319602fd5174b3922bcf72248e65fc715e685590e3aa4676c704fb3e8f99256e7457c3316660925daf341
6
+ metadata.gz: 1414ca1f5aff67e105d3e1ce840608a02ee3542df0952b9bcf3c8e6668f8f0d122d7679d9eac65b16f816b8e665b084d3d8a42f4f91fe1fc06435a9758090c46
7
+ data.tar.gz: 067252f1d834adfada65a2adf42e802392adf4164ae3e729ccd7e75b7693ce43598b1e27f64e4f98cfd862628ce83611aba6565d19fd81519da436de51f3970b
@@ -4,7 +4,7 @@ module TrailGuide
4
4
  module Admin
5
5
  class ExperimentsController < ::TrailGuide::Admin::ApplicationController
6
6
  before_action except: [:index, :import] do
7
- (redirect_to :back rescue redirect_to trail_guide_admin.experiments_path) and return unless experiment.present?
7
+ (redirect_to :back rescue redirect_to trail_guide_admin.experiments_path) unless experiment.present?
8
8
  end
9
9
 
10
10
  before_action :experiments, only: [:index]
@@ -2,7 +2,7 @@ module TrailGuide
2
2
  module Admin
3
3
  class GroupsController < ::TrailGuide::Admin::ApplicationController
4
4
  before_action except: [:index] do
5
- (redirect_to :back rescue redirect_to trail_guide_admin.experiments_path) and return unless group.present?
5
+ (redirect_to :back rescue redirect_to trail_guide_admin.groups_path) unless group.present?
6
6
  end
7
7
 
8
8
  before_action :groups, only: [:index]
@@ -0,0 +1,38 @@
1
+ module TrailGuide
2
+ module Admin
3
+ class OrphansController < ::TrailGuide::Admin::ApplicationController
4
+ before_action except: [:index] do
5
+ (redirect_to :back rescue redirect_to trail_guide_admin.orphans_path) unless orphan.present?
6
+ end
7
+
8
+ before_action :orphans, only: [:index]
9
+ before_action :orphan, only: [:show, :adopt]
10
+
11
+ def index
12
+ end
13
+
14
+ def show
15
+ end
16
+
17
+ def adopt
18
+ TrailGuide.catalog.adopted(@orphan.to_sym)
19
+ flash[:success] = "Cleared references to <code>#{@orphan}</code>! It will reappear if it is encountered by users again."
20
+ if TrailGuide.catalog.orphans.count > 0
21
+ redirect_to trail_guide_admin.orphans_path
22
+ else
23
+ redirect_to trail_guide_admin.experiments_path
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def orphans
30
+ @orphans = TrailGuide.catalog.orphans
31
+ end
32
+
33
+ def orphan
34
+ @orphan, @traces = TrailGuide.catalog.orphans.find { |orphan,_traces| orphan == params[:id].to_s.underscore }
35
+ end
36
+ end
37
+ end
38
+ end
@@ -14,6 +14,15 @@
14
14
  <span class="fas fa-fill" data-toggle="tooltip" title="goals"></span> across
15
15
  <strong><%= number_with_delimiter TrailGuide.catalog.all.count %></strong>
16
16
  <span class="fas fa-flask" data-toggle="tooltip" title="experiments"></span>
17
+ <% unless TrailGuide.configuration.ignore_orphaned_groups? || TrailGuide.catalog.orphans.empty? %>
18
+ &nbsp;&nbsp;&nbsp;
19
+ <%= link_to trail_guide_admin.orphans_url, style: 'text-decoration: none', data: {toggle: 'tooltip'}, title: 'orphans' do %>
20
+ <span class="alert-warning" style="background-color: transparent; boder-color: transparent;">
21
+ <strong><%= number_with_delimiter TrailGuide.catalog.orphans.count %></strong>
22
+ <span class="fas fa-ghost"></span>
23
+ </span>
24
+ <% end %>
25
+ <% end %>
17
26
  </div>
18
27
  <div class="col-sm-3 text-right">
19
28
  <small class="text-muted"><%= TrailGuide.redis_client.id %><%= "/#{TrailGuide.redis.namespace}" if TrailGuide.redis.respond_to?(:namespace) %></small>
@@ -27,7 +27,7 @@
27
27
  <% end %>
28
28
  <% elsif experiment.started? %>
29
29
  <% if experiment.stopped? %>
30
- This experiment has been stopped and he control variant will be returned to all participants until it is restarted or a winner is selected. It ran from <strong><%= format_time(experiment.started_at) %></strong> to <strong><%= format_time(experiment.stopped_at) %></strong>.
30
+ This experiment has been stopped and the control variant will be returned to all participants until it is restarted or a winner is selected. It ran from <strong><%= format_time(experiment.started_at) %></strong> to <strong><%= format_time(experiment.stopped_at) %></strong>.
31
31
  <% elsif experiment.paused? %>
32
32
  This experiment was paused on <strong><%= format_time(experiment.paused_at) %></strong> paused. The control variant will be returned to all participants until it is resumed, restarted or a winner is selected.
33
33
  <% else %>
@@ -1,5 +1,3 @@
1
- <%= render partial: 'trail_guide/admin/orphans/alert' %>
2
-
3
1
  <div class="row justify-content-center">
4
2
  <div class="col-12 col-md-10 col-lg-8">
5
3
  <div class="experiments">
@@ -1,5 +1,3 @@
1
- <%= render partial: 'trail_guide/admin/orphans/alert' %>
2
-
3
1
  <div class="row justify-content-center">
4
2
  <div class="col-12 col-md-10 col-lg-8">
5
3
  <div class="experiments">
@@ -1,11 +1,7 @@
1
1
  <% unless TrailGuide.configuration.ignore_orphaned_groups? || TrailGuide.catalog.orphans.empty? %>
2
2
  <div class="row justify-content-center">
3
3
  <div class="col-sm-12 col-md-10 col-lg-8">
4
- <div class="alert alert-warning alert-dismissable">
5
- <button type="button" class="close" data-dismiss="alert" aria-label="Close">
6
- <span aria-hidden="true">&times;</span>
7
- </button>
8
-
4
+ <div class="alert alert-warning">
9
5
  <h5>
10
6
  <span class="fas fa-ghost"></span>
11
7
  &nbsp;
@@ -16,28 +12,6 @@
16
12
  <p>TrailGuide has detected <strong><%= TrailGuide.catalog.orphans.values.sum(&:count) %></strong> calls to <code>trailguide.convert</code> against <strong><%= TrailGuide.catalog.orphans.count %></strong> unknown group <%= "name".pluralize(TrailGuide.catalog.orphans.count) %>.</p>
17
13
 
18
14
  <p><small>This usually means that the last experiment that belonged to a given group was removed without realizing it, and references to the group were overlooked. <strong>Don't worry, your users won't notice a thing</strong>, and you can find all the logged references below. You can find <%= link_to "more info here.", "https://github.com/markrebec/trailguide#orphaned-groups", target: :blank %></small></p>
19
-
20
- <div class="accordion bg-transparent border-0" id="orphans">
21
- <% TrailGuide.catalog.orphans.each do |orphan,traces| %>
22
- <div class="card">
23
- <button class="btn btn-outline-light text-left btn-block" type="button" data-toggle="collapse" data-target="#orphan-<%= orphan %>" aria-expanded="true" aria-controls="collapseOne">
24
- <strong><code><%= orphan %></code></strong>
25
- </button>
26
-
27
- <div id="orphan-<%= orphan %>" class="collapse" aria-labelledby="orphan-btn-<%= orphan %>" data-parent="#orphans">
28
- <div class="card-body">
29
- <ul style="list-style: none;">
30
- <% traces.each do |trace| %>
31
- <li><code><%= trace %></code></li>
32
- <% end %>
33
- </ul>
34
- </div>
35
- </div>
36
- </div>
37
- <% end %>
38
- </div>
39
-
40
- <p><small>These warnings will expire after 15 minutes of inactivity, and they will disappear automatically once you remove the references listed above and are no longer being reactivated. If you prefer to clear these warnings immediately after cleaning up, you can run <code>TrailGuide.catalog.adopted(:group_name)</code> from a console, rake task, or background job.</small></p>
41
15
  </div>
42
16
  </div>
43
17
  </div>
@@ -0,0 +1,33 @@
1
+ <%= render partial: 'trail_guide/admin/orphans/alert' %>
2
+
3
+ <div class="row justify-content-center">
4
+ <div class="col-12 col-md-10 col-lg-8">
5
+ <div class="experiments">
6
+ <% @orphans.each do |orphan,traces| %>
7
+ <button href="<%= trail_guide_admin.orphan_path(orphan) %>" class="experiment btn btn-outline-warning rounded-lg text-left">
8
+ <div class="row align-items-center">
9
+ <div class="col-12 col-md-8 col-lg-9 experiment-text">
10
+ <h4 id="<%= orphan %>">
11
+ <%= orphan.to_s.humanize.titleize %>
12
+ </h4>
13
+ </div>
14
+ <div class="col-12 col-md-4 col-lg-3 text-center text-md-right">
15
+ <div class="row align-items-center">
16
+ <div class="col-6 col-md-7 col-lg-8 experiment-text text-center">
17
+ </div>
18
+
19
+ <div class="col-6 col-md-5 col-lg-4">
20
+ <h4>
21
+ <span class="fas fa-ghost"></span>
22
+ &times;
23
+ <%= traces.count %>
24
+ </h4>
25
+ </div>
26
+ </div>
27
+ </div>
28
+ </div>
29
+ </button>
30
+ <% end %>
31
+ </div>
32
+ </div>
33
+ </div>
@@ -0,0 +1,32 @@
1
+ <div class="row justify-content-center">
2
+ <div class="col-12 col-md-10 col-lg-8">
3
+ <div class="row align-items-center">
4
+ <div class="col-8 col-lg-10">
5
+ <h1 id="<%= @orphan %>" class="alert-warning" style="background-color: transparent; boder-color: transparent;">
6
+ <span class="fas fa-ghost"></span>
7
+ &nbsp;
8
+ <%= @orphan.to_s.humanize.titleize %>
9
+ </h1>
10
+ </div>
11
+
12
+ <div class="col-4 col-lg-2 text-right">
13
+ </div>
14
+ </div>
15
+
16
+ <div class="alert alert-warning">
17
+ <p>TrailGuide has detected <strong><%= @traces.count %></strong> orphaned calls to <code>trailguide.convert(:<%= @orphan %>)</code>.</p>
18
+
19
+ <p><small>This usually means that the last experiment that belonged to the group was removed without realizing it, and references to the group were overlooked. <strong>Don't worry, your users won't notice a thing</strong>, and you can find all the logged references below. You can find <%= link_to "more info here.", "https://github.com/markrebec/trailguide#orphaned-groups", target: :blank %></small></p>
20
+ </div>
21
+
22
+ <ul style="list-style: none; margin-bottom: 15px;">
23
+ <% @traces.each do |trace| %>
24
+ <li><code><%= trace %></code></li>
25
+ <% end %>
26
+ </ul>
27
+
28
+ <div class="alert alert-info">
29
+ <p><small>These warnings will expire after 15 minutes of inactivity, and they will disappear automatically once you remove the references listed above. If you prefer to clear these warnings immediately after cleaning up, you can run <code>TrailGuide.catalog.adopted(:group_name)</code> from a console, rake task, or background job or <%= link_to 'click here to clear them immediately', trail_guide_admin.adopt_orphan_url(@orphan) %>.</small></p>
30
+ </div>
31
+ </div>
32
+ </div>
@@ -1,5 +1,10 @@
1
1
  TrailGuide::Admin::Engine.routes.draw do
2
- resources :groups, only: [:index, :show]
2
+ resources :groups, only: [:index, :show]
3
+ resources :orphans, only: [:index, :show] do
4
+ member do
5
+ match :adopt, via: [:put, :post, :get]
6
+ end
7
+ end
3
8
 
4
9
  resources :experiments, path: '/', only: [:index, :show] do
5
10
  member do
@@ -21,9 +26,9 @@ TrailGuide::Admin::Engine.routes.draw do
21
26
  end
22
27
 
23
28
  collection do
24
- put '/import', action: :import, as: :import
25
- get '/export', action: :index, as: :export, format: [:json]
26
- get '/scope/:scope', action: :index, as: :scoped
29
+ put '/import', action: :import, as: :import
30
+ get '/export', action: :index, as: :export, format: [:json]
31
+ get '/scope/:scope', action: :index, as: :scoped
27
32
  end
28
33
  end
29
34
  end
@@ -28,6 +28,11 @@ module TrailGuide
28
28
  @config = config
29
29
  end
30
30
 
31
+ def subject
32
+ context.try(:trailguide_user) || context.try(:current_user)
33
+ end
34
+ alias_method :user, :subject
35
+
31
36
  def [](key)
32
37
  raise NotImplementedError, "You must override the `[]` method in your inheriting adapter class"
33
38
  end
@@ -6,6 +6,7 @@ module TrailGuide
6
6
  def initialize(&block)
7
7
  configure do |config|
8
8
  config.namespace = :participants
9
+ # TODO this can be simplified now that adapters have a contextual subject
9
10
  config.lookup = -> (context) {
10
11
  context.try(:trailguide_user).try(:id) ||
11
12
  context.try(:current_user).try(:id)
@@ -2,7 +2,7 @@ module TrailGuide
2
2
  module Experiments
3
3
  class Participant
4
4
  attr_reader :experiment, :participant
5
- delegate :context, to: :participant
5
+ delegate :context, :subject, to: :participant
6
6
 
7
7
  def initialize(experiment, participant)
8
8
  @experiment = experiment
@@ -1,7 +1,7 @@
1
1
  module TrailGuide
2
2
  class Participant
3
3
  attr_reader :context
4
- delegate :key?, :keys, :[], :[]=, :delete, :destroy!, :to_h, to: :adapter
4
+ delegate :key?, :keys, :[], :[]=, :delete, :destroy!, :to_h, :subject, to: :adapter
5
5
 
6
6
  def initialize(context, adapter: nil)
7
7
  @context = context
@@ -2,7 +2,7 @@ module TrailGuide
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 4
5
- PATCH = 4
5
+ PATCH = 5
6
6
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
 
8
8
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trailguide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rebec
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-12 00:00:00.000000000 Z
11
+ date: 2020-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -196,6 +196,7 @@ files:
196
196
  - app/controllers/trail_guide/admin/application_controller.rb
197
197
  - app/controllers/trail_guide/admin/experiments_controller.rb
198
198
  - app/controllers/trail_guide/admin/groups_controller.rb
199
+ - app/controllers/trail_guide/admin/orphans_controller.rb
199
200
  - app/controllers/trail_guide/experiments_controller.rb
200
201
  - app/views/layouts/trail_guide/admin/_calculator.erb
201
202
  - app/views/layouts/trail_guide/admin/_footer.html.erb
@@ -228,6 +229,8 @@ files:
228
229
  - app/views/trail_guide/admin/groups/index.html.erb
229
230
  - app/views/trail_guide/admin/groups/show.html.erb
230
231
  - app/views/trail_guide/admin/orphans/_alert.html.erb
232
+ - app/views/trail_guide/admin/orphans/index.html.erb
233
+ - app/views/trail_guide/admin/orphans/show.html.erb
231
234
  - config/initializers/admin.rb
232
235
  - config/initializers/assets.rb
233
236
  - config/initializers/experiment.rb