Class: TrailGuide::Admin::ExperimentsController
Instance Method Summary
collapse
#experiment_color, #experiment_icon, #experiment_metric, #experiment_metrics_visible?, #experiment_peekable?, #experiment_peeking?, #format_time, #peek_param, #peek_url, #preview_url, #subtitle, #trailguide_user
Instance Method Details
#clear ⇒ Object
144
145
146
147
148
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 144
def clear
experiment.clear_winner!
flash[:success] = "Removed the winner"
redirect_to_experiment experiment
end
|
#convert ⇒ Object
115
116
117
118
119
120
121
122
123
124
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 115
def convert
params[:goal] = nil if params[:goal] == 'converted'
variant = convert_experiment(experiment, params[:goal])
if variant
flash[:info] = "You successfully converted the goal <strong>#{params[:goal].to_s.humanize.titleize}</strong> in the <strong>#{variant.to_s.humanize.titleize}</strong> variant"
else
flash[:info] = "You did not convert the goal <strong>#{params[:goal].to_s.humanize.titleize}</strong>"
end
redirect_to_experiment experiment
end
|
#enroll ⇒ Object
109
110
111
112
113
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 109
def enroll
variant = enroll_experiment(experiment)
flash[:info] = "You were enrolled in the <strong>#{variant.to_s.humanize.titleize}</strong> variant"
redirect_to_experiment experiment
end
|
#import ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 23
def import
import_file = params[:file]
if import_file
if import_file.respond_to?(:read)
state_json = JSON.load(import_file.read)
elsif import_file.respond_to?(:path)
state_json= JSON.load(File.read(import_file.path))
end
TrailGuide.catalog.import(state_json)
flash[:success] = "Experiment state imported successfully"
redirect_to trail_guide_admin.experiments_path
else
raise "Please provide an import file"
end
rescue => e
flash[:error] = "There was a problem importing this file: #{e.message}"
redirect_to trail_guide_admin.experiments_path
end
|
#index ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 13
def index
respond_to do |format|
format.html { render }
format.json {
send_data JSON.pretty_generate(TrailGuide.catalog.export),
filename: "trailguide-#{Rails.env}-#{Time.now.to_i}.json"
}
end
end
|
#join ⇒ Object
126
127
128
129
130
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 126
def join
join_experiment(experiment)
flash[:success] = "You joined the <strong>#{params[:variant].to_s.humanize.titleize}</strong> cohort"
redirect_to_experiment experiment
end
|
#leave ⇒ Object
132
133
134
135
136
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 132
def leave
leave_experiment(experiment)
flash[:success] = "You left the experiment"
redirect_to_experiment experiment
end
|
#pause ⇒ Object
71
72
73
74
75
76
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 71
def pause
experiment.pause!(self)
flash[:success] = "Experiment paused"
redirect_to_experiment experiment
end
|
#reset ⇒ Object
85
86
87
88
89
90
91
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 85
def reset
experiment.stop!(self)
experiment.reset!(self)
flash[:success] = "Experiment reset"
redirect_to_experiment experiment
end
|
#restart ⇒ Object
100
101
102
103
104
105
106
107
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 100
def restart
experiment.stop!(self)
experiment.reset!(self)
experiment.start!(self)
flash[:success] = "Experiment restarted"
redirect_to_experiment experiment
end
|
#resume ⇒ Object
93
94
95
96
97
98
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 93
def resume
experiment.resume!(self)
flash[:success] = "Experiment resumed"
redirect_to_experiment experiment
end
|
#schedule ⇒ Object
61
62
63
64
65
66
67
68
69
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 61
def schedule
experiment.schedule!(schedule_params[:start_at], schedule_params[:stop_at], self)
flash[:success] = "Experiment scheduled for <strong>#{format_time(experiment.started_at)}</strong>"
redirect_to_experiment experiment
rescue => e
flash[:danger] = e.message
redirect_to_experiment experiment
end
|
#show ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 43
def show
@analyzing = params.key?(:analyze)
@analyze_goal = params[:goal].present? ?
params[:goal].underscore.to_sym :
experiment.goals.first.try(:name)
@analyze_method = params[:method].present? ?
params[:method].underscore.to_sym :
:score
end
|
#start ⇒ Object
53
54
55
56
57
58
59
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 53
def start
experiment.reset!(self) if experiment.enable_calibration?
experiment.start!(self)
flash[:success] = "Experiment started"
redirect_to_experiment experiment
end
|
#stop ⇒ Object
78
79
80
81
82
83
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 78
def stop
experiment.stop!(self)
flash[:success] = "Experiment stopped"
redirect_to_experiment experiment
end
|
#winner ⇒ Object
138
139
140
141
142
|
# File 'app/controllers/trail_guide/admin/experiments_controller.rb', line 138
def winner
experiment.declare_winner!(params[:variant], self)
flash[:success] = "Declared <strong>#{params[:variant].to_s.humanize.titleize}</strong> as the winner"
redirect_to_experiment experiment
end
|