Skip to content

Commit ad1fea9

Browse files
authored
Merge pull request #544 from splitrb/exclude-visitor-before-loading-experiment
Avoid hitting up on redis for robots/excluded users.
2 parents 6719fa7 + 7f0bf4c commit ad1fea9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/split/helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Helper
88
def ab_test(metric_descriptor, control = nil, *alternatives)
99
begin
1010
experiment = ExperimentCatalog.find_or_initialize(metric_descriptor, control, *alternatives)
11-
alternative = if Split.configuration.enabled
11+
alternative = if Split.configuration.enabled && !exclude_visitor?
1212
experiment.save
1313
raise(Split::InvalidExperimentsFormatError) unless (Split.configuration.experiments || {}).fetch(experiment.name.to_sym, {})[:combined_experiments].nil?
1414
trial = Trial.new(:user => ab_user, :experiment => experiment,

spec/helper_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,11 @@ def should_finish_experiment(experiment_name, should_finish=true)
564564
expect(alternative).to eq experiment.control.name
565565
end
566566

567+
it 'should not create a experiment' do
568+
ab_test('link_color', 'blue', 'red')
569+
expect(Split::Experiment.new('link_color')).to be_a_new_record
570+
end
571+
567572
it "should not increment the participation count" do
568573

569574
previous_red_count = Split::Alternative.new('red', 'link_color').participant_count

0 commit comments

Comments
 (0)