lib/vwo/core/bucketer.rb
# Calculate if this user should become part of the campaign or not
# @param[String]         :user_id     The unique ID assigned to a user
# @param[Dict]           :campaign    For getting traffic allotted to the campaign
# @return[Boolean]                    If User is a part of Campaign or not
Calculate if this user should become part of the campaign or not
Calculate if this user should become part of the campaign or not
def user_part_of_campaign?(user_id, campaign)
        unless valid_value?(user_id)
          @logger.log(
            LogLevelEnum::ERROR,
            format(LogMessageEnum::ErrorMessages::INVALID_USER_ID, file: FILE, user_id: user_id, method: 'is_user_part_of_campaign')
          )
          return false
        end
        if campaign.nil?
          @logger.log(
            LogLevelEnum::ERROR,
            format(LogMessageEnum::ErrorMessages::INVALID_CAMPAIGN, file: FILE, method: 'is_user_part_of_campaign')
          )
          return false
        end
        traffic_allocation = campaign['percentTraffic']
        value_assigned_to_user = get_bucket_value_for_user(user_id, campaign)
        is_user_part = (value_assigned_to_user != 0) && value_assigned_to_user <= traffic_allocation
        @logger.log(
          LogLevelEnum::INFO,
          format(LogMessageEnum::InfoMessages::USER_ELIGIBILITY_FOR_CAMPAIGN, file: FILE, user_id: user_id, is_user_part: is_user_part)
        )
        is_user_part
      end
def user_part_of_campaign? ( user_id , campaign ) unless valid_value? ( user_id ) @logger . log ( LogLevelEnum :: ERROR , format ( LogMessageEnum :: ErrorMessages :: INVALID_USER_ID , file : FILE , user_id : user_id , method : 'is_user_part_of_campaign' ) ) return false end if campaign . nil? @logger . log ( LogLevelEnum :: ERROR , format ( LogMessageEnum :: ErrorMessages :: INVALID_CAMPAIGN , file : FILE , method : 'is_user_part_of_campaign' ) ) return false end traffic_allocation = campaign [ 'percentTraffic' ] value_assigned_to_user = get_bucket_value_for_user ( user_id , campaign ) is_user_part = ( value_assigned_to_user != 0 ) && value_assigned_to_user <= traffic_allocation @logger . log ( LogLevelEnum :: INFO , format ( LogMessageEnum :: InfoMessages :: USER_ELIGIBILITY_FOR_CAMPAIGN , file : FILE , user_id : user_id , is_user_part : is_user_part ) ) is_user_part end
Calculate if this user should become part of the campaign or not
Calculate if this user should become part of the campaign or not
user_id
<not_specific>
campaign
<not_specific>
param[String]
:user_id The unique ID assigned to a user
: user_id The unique ID assigned to a user
param[Dict]
:campaign For getting traffic allotted to the campaign
: campaign For getting traffic allotted to the campaign
return[Boolean]
If User is a part of Campaign or not
If User is a part of Campaign or not