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:
Diffstat (limited to 'lib/gitlab/database/convert_feature_category_to_group_label.rb')
-rw-r--r--lib/gitlab/database/convert_feature_category_to_group_label.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/gitlab/database/convert_feature_category_to_group_label.rb b/lib/gitlab/database/convert_feature_category_to_group_label.rb
new file mode 100644
index 00000000000..5a4599312ba
--- /dev/null
+++ b/lib/gitlab/database/convert_feature_category_to_group_label.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Database
+ class ConvertFeatureCategoryToGroupLabel
+ STAGES_URL = 'https://gitlab.com/gitlab-com/www-gitlab-com/-/raw/master/data/stages.yml'
+
+ def initialize(feature_category)
+ @feature_category = feature_category
+ end
+
+ def execute
+ feature_categories_map[feature_category]
+ end
+
+ private
+
+ attr_reader :feature_category
+
+ def stages
+ response = Gitlab::HTTP.get(STAGES_URL)
+
+ YAML.safe_load(response) if response.success?
+ end
+
+ def feature_categories_map
+ stages['stages'].each_with_object({}) do |(_, stage), result|
+ stage['groups'].each do |group_name, group|
+ group['categories'].each do |category|
+ result[category] = "group::#{group_name.sub('_', ' ')}"
+ end
+ end
+ end
+ end
+ end
+ end
+end