Module: Conductor
- Defined in:
- lib/conductor.rb,
lib/conductor/engine.rb,
lib/conductor/roll_up.rb,
lib/conductor/version.rb,
lib/conductor/weights.rb,
lib/conductor/experiment.rb,
app/models/conductor/experiment/raw.rb,
app/models/conductor/experiment/daily.rb,
app/models/conductor/experiment/weight.rb,
app/models/conductor/experiment/history.rb,
app/helpers/conductor/application_helper.rb,
app/controllers/conductor/dashboard_controller.rb,
app/controllers/conductor/application_controller.rb
Defined Under Namespace
Modules: ApplicationHelper, DashboardHelper Classes: ApplicationController, DashboardController, Engine, Experiment, RollUp, Weights
Constant Summary collapse
- MAX_WEIGHTING_FACTOR =
1.25
- EQUALIZATION_PERIOD_DEFAULT =
7
- DBG =
false
- VERSION =
"0.9.4"
Class Method Summary collapse
- .attribute_for_weighting ⇒ Object
-
.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.
-
.cache ⇒ Object
attr_accessor :cache.
- .equalization_period ⇒ Object
-
.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.
- .identity ⇒ Object
-
.identity=(value) ⇒ Object
Specifies a unique identity for the current visitor.
- .inclusion_period ⇒ Object
-
.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.
- .log(msg) ⇒ Object
- .reset_identity ⇒ Object
- .sanitize(str) ⇒ Object
Class Method Details
.attribute_for_weighting ⇒ Object
73 74 75 |
# File 'lib/conductor.rb', line 73 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
68 69 70 71 |
# File 'lib/conductor.rb', line 68 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 |
.cache ⇒ Object
attr_accessor :cache
15 16 17 |
# File 'lib/conductor.rb', line 15 def self.cache $cache || Rails.cache end |
.equalization_period ⇒ Object
60 61 62 |
# File 'lib/conductor.rb', line 60 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
55 56 57 58 |
# File 'lib/conductor.rb', line 55 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 |
.identity ⇒ Object
27 28 29 |
# File 'lib/conductor.rb', line 27 def identity return (@conductor_identity || 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.
23 24 25 |
# File 'lib/conductor.rb', line 23 def identity=(value) @conductor_identity = value end |
.inclusion_period ⇒ Object
44 45 46 |
# File 'lib/conductor.rb', line 44 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
38 39 40 41 42 |
# File 'lib/conductor.rb', line 38 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
77 78 79 |
# File 'lib/conductor.rb', line 77 def log(msg) puts msg if DBG end |
.reset_identity ⇒ Object
31 32 33 |
# File 'lib/conductor.rb', line 31 def reset_identity @conductor_identity = SecureRandom.hex(16) end |
.sanitize(str) ⇒ Object
81 82 83 |
# File 'lib/conductor.rb', line 81 def sanitize(str) str.gsub(/\s/,'_').downcase end |