Sha256: 1237389597947cbe1fc2d62703e969bb222ceaa51e8966a641e7d0142d07bc73

Contents?: true

Size: 876 Bytes

Versions: 8

Compression:

Stored size: 876 Bytes

Contents

# frozen_string_literal: true

require "gitlab_reviewbot/gitlab"

module Danger
  module AssignStrategies
    class LeastBusyStrategy < Strategy
      def assignees(amount)
        # This doesn't fetch the review count for the users so we need to fetch it separately later
        users_in_group = fetch_users_in_group
        invalid_assignees = [fetch_author] + fetch_assigned_reviewers

        group_users_with_reviews_pending = client.users_with_pending_mr_review(project_id).filter { |u| users_in_group.include? u }
        group_users_without_reviews_pending = users_in_group.filter { |u| !group_users_with_reviews_pending.include? u }

        candidates = (group_users_with_reviews_pending + group_users_without_reviews_pending).filter { |u| !invalid_assignees.include? u }
        candidates.shuffle.sort_by(&:review_count).first(amount)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
danger-gitlab_reviewbot-1.2.3 lib/gitlab_reviewbot/strategies/least_busy.rb
danger-gitlab_reviewbot-1.2.1 lib/gitlab_reviewbot/strategies/least_busy.rb
danger-gitlab_reviewbot-1.2.0 lib/gitlab_reviewbot/strategies/least_busy.rb
danger-gitlab_reviewbot-1.1.10 lib/gitlab_reviewbot/strategies/least_busy.rb
danger-gitlab_reviewbot-1.1.9 lib/gitlab_reviewbot/strategies/least_busy.rb
danger-gitlab_reviewbot-1.1.8 lib/gitlab_reviewbot/strategies/least_busy.rb
danger-gitlab_reviewbot-1.1.6 lib/gitlab_reviewbot/strategies/least_busy.rb
danger-gitlab_reviewbot-1.1.5 lib/gitlab_reviewbot/strategies/least_busy.rb