Method: Conductor::Weights.compute
- Defined in:
- lib/conductor/weights.rb
.compute(group_name, alternatives) ⇒ Object
Computes the weights for a group based on the attribute for weighting and activity for the inclusion period.
If no conversions have taken place yet for a group, all alternatives are weighted equally.
TODO: add notification table and all notification if there are no conversions and we are out of the equalization period
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/conductor/weights.rb', line 34 def compute(group_name, alternatives) Conductor::Experiment::Weight.delete_all(:group_name => group_name) data = [] equalization_period_data = Conductor::Experiment::Daily.find_equalization_period_stats_for(group_name, alternatives) post_equalization_data = Conductor::Experiment::Daily.find_post_equalization_period_stats_for(group_name, alternatives) # handle all post_equalization_data max_weight = 0 unless post_equalization_data.empty? total = post_equalization_data.sum_it(Conductor.attribute_for_weighting) data = (total > 0) ? compute_weights(post_equalization_data, total, max_weight) : assign_equal_weights(post_equalization_data) end # add weights for recently launched weight_recently_launched(data, max_weight, equalization_period_data) unless equalization_period_data.empty? # add to database update_weights_in_db(group_name, data) end |