lib/vwo/core/variation_decider.rb
# It extracts the weights from all the variations inside the campaign
# and scales them so that the total sum of eligible variations' weights become 100%
#
# 1. variations
It extracts the weights from all the variations inside the campaign
and scales them so that the total sum of eligible variations' weights become 100%

1. variations
It extracts the weights from all the variations inside the campaign and scales them so that the total sum of eligible variations ' weights become 100% 1 . variations
def scale_variation_weights(variations)
        total_weight = variations.reduce(0) { |final_weight, variation| final_weight + variation['weight'].to_f }
        if total_weight == 0
          weight = 100 / variations.length
          variations.each do |variation|
            variation['weight'] = weight
          end
        else
          variations.each do |variation|
            variation['weight'] = (variation['weight'] / total_weight) * 100
          end
        end
      end
def scale_variation_weights ( variations ) total_weight = variations . reduce ( 0 ) { | final_weight , variation | final_weight + variation [ 'weight' ] . to_f } if total_weight == 0 weight = 100 / variations . length variations . each do | variation | variation [ 'weight' ] = weight end else variations . each do | variation | variation [ 'weight' ] = ( variation [ 'weight' ] / total_weight ) * 100 end end end
It extracts the weights from all the variations inside the campaign
and scales them so that the total sum of eligible variations' weights become 100%
It extracts the weights from all the variations inside the campaign and scales them so that the total sum of eligible variations ' weights become 100%
variations
<not_specific>