Class: Ci::Pipelines::AutoCleanupService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/ci/pipelines/auto_cleanup_service.rb

Constant Summary collapse

BATCH_SIZE =
50
OTHER_STATUSES_GROUP =
'other'

Instance Method Summary collapse

Constructor Details

#initialize(project:) ⇒ AutoCleanupService

Returns a new instance of AutoCleanupService.



11
12
13
14
# File 'app/services/ci/pipelines/auto_cleanup_service.rb', line 11

def initialize(project:)
  @project = project
  @processing_cache = cache_store.read
end

Instance Method Details

#executeObject



16
17
18
19
20
21
22
23
24
25
# File 'app/services/ci/pipelines/auto_cleanup_service.rb', line 16

def execute
  destroyable_pipelines, skipped_pipelines = load_destroyable_pipelines

  Ci::DestroyPipelineService
    .new(project, nil)
    .unsafe_execute(destroyable_pipelines, skip_cancel: true)

  ServiceResponse.success(payload: { destroyed_pipelines_size: destroyable_pipelines.size,
                                     skipped_pipelines_size: skipped_pipelines.size })
end