Class: Packages::Npm::DeprecatePackageService
- Inherits:
-
BaseService
- Object
- BaseService
- Packages::Npm::DeprecatePackageService
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/packages/npm/deprecate_package_service.rb
Constant Summary collapse
- BATCH_SIZE =
50
Constants inherited from BaseService
BaseService::UnauthorizedError
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(project, params) ⇒ DeprecatePackageService
constructor
A new instance of DeprecatePackageService.
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
Constructor Details
#initialize(project, params) ⇒ DeprecatePackageService
Returns a new instance of DeprecatePackageService.
10 11 12 |
# File 'app/services/packages/npm/deprecate_package_service.rb', line 10 def initialize(project, params) super(project, nil, params) end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/packages/npm/deprecate_package_service.rb', line 14 def execute = false packages.select(:id, :version, :package_type).each_batch(of: BATCH_SIZE) do |relation| attributes = relation..filter_map { |package| (package) } next if attributes.empty? package_ids = attributes.pluck(:package_id) # rubocop:disable CodeReuse/ActiveRecord, Database/AvoidUsingPluckWithoutLimit -- This is a hash, not an ActiveRecord relation. ApplicationRecord.transaction do ::Packages::Npm::Metadatum.upsert_all(attributes) ::Packages::Package.id_in(package_ids).update_all(status: package_status) end = true end if ::Packages::Npm::CreateMetadataCacheWorker.perform_async(project.id, package_name) end ServiceResponse.success end |