Class: Conductor

Inherits:
Object
  • Object
show all
Defined in:
lib/conductor.rb,
lib/conductor/roll_up.rb,
lib/conductor/weights.rb,
lib/conductor/experiment.rb,
lib/conductor/controller/dashboard.rb

Defined Under Namespace

Modules: Controller Classes: Experiment, RollUp, Weights

Constant Summary collapse

MAX_WEIGHTING_FACTOR =
1.25
EQUALIZATION_PERIOD_DEFAULT =
7
DBG =
false

Class Method Summary collapse

Class Method Details

.attribute_for_weightingObject



60
61
62
# File 'lib/conductor.rb', line 60

def attribute_for_weighting
  return (@attribute_for_weighting || :conversion_value)
end

.attribute_for_weighting=(value) ⇒ Object

The attribute for weighting specifies if the conversion_value OR number of conversions should be used to calculate the weight. The default is conversion_value.

TODO: Allow of avg_conversion_value where acv = conversion_value / conversions



55
56
57
58
# File 'lib/conductor.rb', line 55

def attribute_for_weighting=(value)
  raise "Conductor.attribute_for_weighting must be either :views, :conversions or :conversion_value (default)" unless [:views, :conversions, :conversion_value].include?(value) 
  @attribute_for_weighting = value
end

.cacheObject



19
20
21
# File 'lib/conductor.rb', line 19

def self.cache
  @@cache || Rails.cache
end

.equalization_periodObject



47
48
49
# File 'lib/conductor.rb', line 47

def equalization_period
  return (@equalization_period || EQUALIZATION_PERIOD_DEFAULT)
end

.equalization_period=(value) ⇒ Object

The equalization period is the initial amount of time, in days, that conductor should apply the max_weighting_factor towards a new alternative to ensure that it receives a far shot of performing.

If an equalization period was not used then any new alternative would immediately be weighed very low since it has no conversions and would never have a chance of performing



42
43
44
45
# File 'lib/conductor.rb', line 42

def equalization_period=(value)
  raise "Conductor.equalization_period must be a positive number > 0" unless value.is_a?(Numeric) && value > 0
  @equalization_period = value
end

.identityObject



31
32
33
# File 'lib/conductor.rb', line 31

def identity
  return (@conductor_identity || ActiveSupport::SecureRandom.hex(16))
end

.identity=(value) ⇒ Object

Specifies a unique identity for the current visitor. If no identity is specified then a random value is selected. Conductor makes sure that the same visitor will always see the same alternative selections to reduce confusion.



27
28
29
# File 'lib/conductor.rb', line 27

def identity=(value)
  @conductor_identity = value
end

.log(msg) ⇒ Object



64
65
66
# File 'lib/conductor.rb', line 64

def log(msg)
  puts msg if DBG
end

.sanitize(str) ⇒ Object



68
69
70
# File 'lib/conductor.rb', line 68

def sanitize(str)
  str.gsub(/\s/,'_').downcase
end