Class: Ci::ResourceGroups::AssignResourceFromResourceGroupService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/ci/resource_groups/assign_resource_from_resource_group_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#execute(resource_group) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


7
8
9
10
11
12
13
# File 'app/services/ci/resource_groups/assign_resource_from_resource_group_service.rb', line 7

def execute(resource_group)
  free_resources = resource_group.resources.free.count

  resource_group.builds.waiting_for_resource.take(free_resources).each do |build|
    build.enqueue_waiting_for_resource
  end
end