Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-03 18:09:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-03 18:09:24 +0300
commit6cbb93596d65dff377372f4b50da932dcf6dc514 (patch)
treec381ee98bd0fb444665f11c452b8e8f0e8e7731a /app/experiments/application_experiment.rb
parentce9b8ee20d039da5f93e37d0ab3905813f3dd7bc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/experiments/application_experiment.rb')
-rw-r--r--app/experiments/application_experiment.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/app/experiments/application_experiment.rb b/app/experiments/application_experiment.rb
index 92bd8d5783b..1c9a3c5f37f 100644
--- a/app/experiments/application_experiment.rb
+++ b/app/experiments/application_experiment.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-class ApplicationExperiment < Gitlab::Experiment
+class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/NamespacedClass
def enabled?
- return false if Feature::Definition.get(name).nil? # there has to be a feature flag yaml file
+ return false if Feature::Definition.get(feature_flag_name).nil? # there has to be a feature flag yaml file
return false unless Gitlab.dev_env_or_com? # we're in an environment that allows experiments
- Feature.get(name).state != :off # rubocop:disable Gitlab/AvoidFeatureGet
+ Feature.get(feature_flag_name).state != :off # rubocop:disable Gitlab/AvoidFeatureGet
end
def publish(_result)
@@ -26,11 +26,15 @@ class ApplicationExperiment < Gitlab::Experiment
private
def resolve_variant_name
- return variant_names.first if Feature.enabled?(name, self, type: :experiment, default_enabled: :yaml)
+ return variant_names.first if Feature.enabled?(feature_flag_name, self, type: :experiment, default_enabled: :yaml)
nil # Returning nil vs. :control is important for not caching and rollouts.
end
+ def feature_flag_name
+ name.tr('/', '_')
+ end
+
# Cache is an implementation on top of Gitlab::Redis::SharedState that also
# adheres to the ActiveSupport::Cache::Store interface and uses the redis
# hash data type.
@@ -48,7 +52,7 @@ class ApplicationExperiment < Gitlab::Experiment
# default cache key strategy. So running `cache.fetch("foo:bar", "value")`
# would create/update a hash with the key of "foo", with a field named
# "bar" that has "value" assigned to it.
- class Cache < ActiveSupport::Cache::Store
+ class Cache < ActiveSupport::Cache::Store # rubocop:disable Gitlab/NamespacedClass
# Clears the entire cache for a given experiment. Be careful with this
# since it would reset all resolved variants for the entire experiment.
def clear(key:)