Class: GitlabQuality::TestTooling::CodeCoverage::CategoryOwners

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/gitlab_quality/test_tooling/code_coverage/category_owners.rb

Constant Summary collapse

SOURCE_URL =
URI('https://gitlab.com/gitlab-com/www-gitlab-com/raw/master/data/stages.yml')
BASE_DELAY =

seconds

1
MAX_RETRIES =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#exponential_delay_with_jitter

Constructor Details

#initializeCategoryOwners

Returns a new instance of CategoryOwners.



37
38
39
40
41
42
43
44
# File 'lib/gitlab_quality/test_tooling/code_coverage/category_owners.rb', line 37

def initialize
  @feature_categories_map = {}
  @hierarchy = {}

  yaml_file = fetch_yaml_file
  yaml_content = YAML.load(yaml_file)
  populate_ownership_hierarchy(yaml_content)
end

Instance Attribute Details

#hierarchyHash (readonly)

Returns Feature category ownership hierarchy, section -> stage -> group -> [feature_categories].

Examples:

Return value

{
  "team_planning" => {             # section
    "project_management" => {      # stage
      "plan" => [                  # group
        "dev",                     # feature_category
        "service_desk"             # feature_category
      ],
      "product_planning" => [      # group
        "portfolio_management",    # feature_category
        ...
      ]
    }
  },
  ...
}

Returns:

  • (Hash)

    Feature category ownership hierarchy, section -> stage -> group -> [feature_categories]



35
36
37
# File 'lib/gitlab_quality/test_tooling/code_coverage/category_owners.rb', line 35

def hierarchy
  @hierarchy
end

Instance Method Details

#as_db_tableArray<Hash>

Returns Flattened feature category ownership.

Examples:

Return value

[
  { feature_category: "team_planning", group: "project_management", stage: "plan", section: "dev" },
  { feature_category: "service_desk", group: "project_management", stage: "plan", section: "dev" },
  { feature_category: "portfolio_management", group: "product_planning", stage: "plan", section: "dev" }
  ...
]

Returns:

  • (Array<Hash>)

    Flattened feature category ownership



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/gitlab_quality/test_tooling/code_coverage/category_owners.rb', line 54

def as_db_table
  hierarchy.each_with_object([]) do |(section, stages), flattened_hierarchy|
    next unless stages

    stages.each do |stage, groups|
      next unless groups

      groups.each do |group, feature_categories|
        Array(feature_categories).each do |feature_category|
          flattened_hierarchy << {
            feature_category: feature_category,
            group: group,
            stage: stage,
            section: section
          }
        end
      end
    end
  end
end

#feature_categories_to_teamsHash

Returns Mapping of feature categories to teams (i.e., groups, stages, sections).

Examples:

Return value

{
  "team_planning" => { group: "project_management", stage: "plan", section: "dev" },
  "service_desk" => { group: "project_management", stage: "plan", section: "dev" },
  "portfolio_management" => { group: "product_planning", stage: "plan", section: "dev" },
  ...
}

Returns:

  • (Hash)

    Mapping of feature categories to teams (i.e., groups, stages, sections)



83
84
85
86
# File 'lib/gitlab_quality/test_tooling/code_coverage/category_owners.rb', line 83

def feature_categories_to_teams
  populate_feature_categories_map(hierarchy)
  @feature_categories_map
end