Class: GitlabQuality::TestTooling::LabelsInference

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.fetch_json(json_url) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/gitlab_quality/test_tooling/labels_inference.rb', line 39

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

#infer_labels_from_feature_category(feature_category) ⇒ Object



18
19
20
21
22
23
# File 'lib/gitlab_quality/test_tooling/labels_inference.rb', line 18

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



14
15
16
# File 'lib/gitlab_quality/test_tooling/labels_inference.rb', line 14

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



25
26
27
# File 'lib/gitlab_quality/test_tooling/labels_inference.rb', line 25

def product_group_from_feature_category(feature_category)
  categories_mapping.dig(feature_category, 'group')
end