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/rails/controllers/dashboard.rb

Defined Under Namespace

Modules: Controller Classes: Experiment, RollUp, Weights

Constant Summary collapse

MAX_WEIGHTING_FACTOR =
1.25
EQUALIZATION_PERIOD_DEFAULT =
7
MINIMUM_CONVERSIONS_PER_GROUP_DEFAULT =
10
DBG =
false

Class Method Summary collapse

Class Method Details

.attribute_for_weightingObject



76
77
78
# File 'lib/conductor.rb', line 76

def attribute_for_weighting
  return (@attribute_for_weighting || :conversions)
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 conversions.

TODO: Change this to only use conversion rate when normalization is figured out



71
72
73
74
# File 'lib/conductor.rb', line 71

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



9
10
11
# File 'lib/conductor.rb', line 9

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

.equalization_periodObject



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

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



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

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



21
22
23
# File 'lib/conductor.rb', line 21

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.



17
18
19
# File 'lib/conductor.rb', line 17

def identity=(value)
  @conductor_identity = value
end

.inclusion_periodObject



34
35
36
# File 'lib/conductor.rb', line 34

def inclusion_period
  return (@inclusion_period || 14)
end

.inclusion_period=(value) ⇒ Object

The number of days to include when calculating weights The inclusion period MUST be higher than then equalization period The default is 14 days



28
29
30
31
32
# File 'lib/conductor.rb', line 28

def inclusion_period=(value)
  raise "Conductor.inclusion_period must be a positive number > 0" unless value.is_a?(Numeric) && value > 0
  raise "Conductor.inclusion_period must be greater than the equalization period" if value < equalization_period
  @inclusion_period = value
end

.log(msg) ⇒ Object



80
81
82
# File 'lib/conductor.rb', line 80

def log(msg)
  puts msg if DBG
end

.minimum_conversions_per_groupObject



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

def minimum_conversions_per_group
  return (@minimum_conversions_per_group || MINIMUM_CONVERSIONS_PER_GROUP_DEFAULT)
end

.minimum_conversions_per_group=(value) ⇒ Object

The minimum number of conversions that a group needs to have in TOTAL before weighting is allowed.

TODO: trigger a notification if a post equalized group hits below this number



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

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

.sanitize(str) ⇒ Object



84
85
86
# File 'lib/conductor.rb', line 84

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