Class: RailsOnboarding::Admin::AbTestsController
Overview
Admin A/B tests controller
View and toggle the A/B tests defined in RailsOnboarding.configuration.ab_tests,
and inspect their results. Tests are config-defined (see RailsOnboarding::AbTestable),
so there is no create/edit/destroy here - only viewing and enabling/disabling.
Constant Summary
BaseController::DEFAULT_PER_PAGE, BaseController::MAX_PER_PAGE
Instance Method Summary
collapse
Instance Method Details
#export ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
|
# File 'app/controllers/rails_onboarding/admin/ab_tests_controller.rb', line 45
def export
results = calculate_results(@test_name, @test_config)
respond_to do |format|
format.csv do
send_data generate_csv_export(results),
filename: "ab_test_#{@test_name}_results_#{Date.current}.csv",
type: "text/csv"
end
end
end
|
#index ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/rails_onboarding/admin/ab_tests_controller.rb', line 12
def index
@ab_tests = ab_tests_collection
@active_tests = @ab_tests.select { |t| t[:enabled] }
@inactive_tests = @ab_tests.reject { |t| t[:enabled] }
@pagy, page_of_tests = paginate(@active_tests + @inactive_tests)
@page_active_tests = page_of_tests.select { |t| t[:enabled] }
@page_inactive_tests = page_of_tests.reject { |t| t[:enabled] }
end
|
#show ⇒ Object
29
30
31
|
# File 'app/controllers/rails_onboarding/admin/ab_tests_controller.rb', line 29
def show
@results = calculate_results(@test_name, @test_config)
end
|
#start ⇒ Object
33
34
35
36
37
|
# File 'app/controllers/rails_onboarding/admin/ab_tests_controller.rb', line 33
def start
set_enabled(true)
flash[:notice] = "A/B test '#{@test_name}' started"
redirect_to admin_ab_test_path(@test_name)
end
|
#stop ⇒ Object
39
40
41
42
43
|
# File 'app/controllers/rails_onboarding/admin/ab_tests_controller.rb', line 39
def stop
set_enabled(false)
flash[:notice] = "A/B test '#{@test_name}' stopped"
redirect_to admin_ab_test_path(@test_name)
end
|