Welcome to mirror list, hosted at ThFree Co, Russian Federation.

assign_resource_from_resource_group_service.rb « resource_groups « ci « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9e3e6de3928e573b96b83594afc1c8fad5d18dc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

module Ci
  module ResourceGroups
    class AssignResourceFromResourceGroupService < ::BaseService
      # rubocop: disable CodeReuse/ActiveRecord
      def execute(resource_group)
        free_resources = resource_group.resources.free.count

        resource_group.processables.waiting_for_resource.take(free_resources).each do |processable|
          processable.enqueue_waiting_for_resource
        end
      end
      # rubocop: enable CodeReuse/ActiveRecord
    end
  end
end