Class: GitlabQuality::TestTooling::LabelsInference
- Inherits:
-
Object
- Object
- GitlabQuality::TestTooling::LabelsInference
- Defined in:
- lib/gitlab_quality/test_tooling/labels_inference.rb
Constant Summary collapse
- WWW_GITLAB_COM_SITE =
'https://about.gitlab.com'- WWW_GITLAB_COM_GROUPS_JSON =
"#{WWW_GITLAB_COM_SITE}/groups.json".freeze
- WWW_GITLAB_COM_CATEGORIES_JSON =
"#{WWW_GITLAB_COM_SITE}/categories.json".freeze
- EM_KEYS =
{ all: %w[engineering_managers backend_engineering_managers frontend_engineering_managers fullstack_managers], generic: %w[engineering_managers], backend: %w[backend_engineering_managers], frontend: %w[frontend_engineering_managers], fullstack: %w[fullstack_managers] }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #all_group_labels ⇒ Object
- #engineering_managers_from_product_group(product_group, *scopes) ⇒ Object
- #group_data_from_label(label) ⇒ Object
- #infer_labels_from_feature_category(feature_category) ⇒ Object
- #infer_labels_from_product_group(product_group) ⇒ Object
- #product_group_from_feature_category(feature_category) ⇒ Object
- #product_managers_from_product_group(product_group) ⇒ Object
Class Method Details
.fetch_json(json_url) ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/gitlab_quality/test_tooling/labels_inference.rb', line 92 def self.fetch_json(json_url) json = with_retries { HTTParty.get(json_url, format: :plain) } JSON.parse(json) rescue JSON::ParserError Runtime::Logger.debug("#{self.class.name}##{__method__} attempted to parse invalid JSON:\n\n#{json}") {} end |
Instance Method Details
#all_group_labels ⇒ Object
56 57 58 |
# File 'lib/gitlab_quality/test_tooling/labels_inference.rb', line 56 def all_group_labels groups_mapping.filter_map { |_key, data| data['label'] }.uniq end |
#engineering_managers_from_product_group(product_group, *scopes) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/gitlab_quality/test_tooling/labels_inference.rb', line 60 def engineering_managers_from_product_group(product_group, *scopes) group_data = groups_mapping[product_group] return [] unless group_data default_scope = scopes.empty? scopes = [:all] if default_scope ems = resolve_ems(group_data, scopes, default_scope) normalize_mentions(ems) end |
#group_data_from_label(label) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gitlab_quality/test_tooling/labels_inference.rb', line 37 def group_data_from_label(label) return unless label groups_mapping.each do |key, data| next unless label.casecmp?(data['label']) return data.merge('key' => key) end nil end |
#infer_labels_from_feature_category(feature_category) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/gitlab_quality/test_tooling/labels_inference.rb', line 26 def infer_labels_from_feature_category(feature_category) [ categories_mapping.dig(feature_category, 'label'), *infer_labels_from_product_group(categories_mapping.dig(feature_category, 'group')) ].compact.to_set end |
#infer_labels_from_product_group(product_group) ⇒ Object
22 23 24 |
# File 'lib/gitlab_quality/test_tooling/labels_inference.rb', line 22 def infer_labels_from_product_group(product_group) [groups_mapping.dig(product_group, 'label')].compact.to_set end |
#product_group_from_feature_category(feature_category) ⇒ Object
33 34 35 |
# File 'lib/gitlab_quality/test_tooling/labels_inference.rb', line 33 def product_group_from_feature_category(feature_category) categories_mapping.dig(feature_category, 'group') end |
#product_managers_from_product_group(product_group) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/gitlab_quality/test_tooling/labels_inference.rb', line 49 def product_managers_from_product_group(product_group) group_data = groups_mapping[product_group] return [] unless group_data normalize_mentions(Array(group_data['product_managers']).compact) end |