diff options
Diffstat (limited to 'lib/gitlab/experimentation/experiment.rb')
-rw-r--r-- | lib/gitlab/experimentation/experiment.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/gitlab/experimentation/experiment.rb b/lib/gitlab/experimentation/experiment.rb index e594c3bedeb..36cd673a38f 100644 --- a/lib/gitlab/experimentation/experiment.rb +++ b/lib/gitlab/experimentation/experiment.rb @@ -3,17 +3,21 @@ module Gitlab module Experimentation class Experiment + FEATURE_FLAG_SUFFIX = "_experiment_percentage" + attr_reader :key, :tracking_category, :use_backwards_compatible_subject_index def initialize(key, **params) @key = key @tracking_category = params[:tracking_category] @use_backwards_compatible_subject_index = params[:use_backwards_compatible_subject_index] - - @experiment_percentage = Feature.get(:"#{key}_experiment_percentage").percentage_of_time_value # rubocop:disable Gitlab/AvoidFeatureGet end def active? + # TODO: just touch a feature flag + # Temporary change, we will change `experiment_percentage` in future to `Feature.enabled? + Feature.enabled?(feature_flag_name, type: :experiment, default_enabled: :yaml) + ::Gitlab.dev_env_or_com? && experiment_percentage > 0 end @@ -25,7 +29,17 @@ module Gitlab private - attr_reader :experiment_percentage + def experiment_percentage + feature_flag.percentage_of_time_value + end + + def feature_flag + Feature.get(feature_flag_name) # rubocop:disable Gitlab/AvoidFeatureGet + end + + def feature_flag_name + :"#{key}#{FEATURE_FLAG_SUFFIX}" + end end end end |