Sha256: 99249f2492dc9437a3f724298fd7d19888b05b9c231daf6db5dd9833e979098d

Contents?: true

Size: 1.32 KB

Versions: 17

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

require 'json'

module GitlabQuality
  module TestTooling
    module Report
      module Concerns
        module FindSetDri
          def set_dri_via_group(product_group, test)
            parse_json_with_sets
            fetch_stage_sets(test)

            return @sets.sample['username'] if @stage_sets.empty?

            fetch_group_sets(product_group)

            if @group_sets.empty?
              @stage_sets.sample['username']
            else
              @group_sets.sample['username']
            end
          end

          private

          def parse_json_with_sets
            response = Support::HttpRequest.make_http_request(
              url: 'https://gitlab-org.gitlab.io/gitlab-roulette/roulette.json'
            )
            @sets = JSON.parse(response.body).select { |user| user['role'].include?('software-engineer-in-test') }
          end

          def fetch_stage_sets(test)
            @stage_sets = @sets.select do |user|
              user['role'].include?(test.stage.split("_").map(&:capitalize).join(" "))
            end
          end

          def fetch_group_sets(product_group)
            @group_sets = @stage_sets.select do |user|
              user['role'].downcase.tr(' ', '_').include?(product_group)
            end
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
gitlab_quality-test_tooling-1.11.0 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.10.1 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.10.0 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.9.0 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.8.1 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.8.0 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.7.0 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.5.4 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.5.3 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.5.2 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.5.1 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.5.0 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.4.0 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.3.0 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.2.0 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.1.0 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb
gitlab_quality-test_tooling-1.0.0 lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb