Class: Ci::DeleteObjectsService

Inherits:
Object
  • Object
show all
Defined in:
app/services/ci/delete_objects_service.rb

Constant Summary collapse

TransactionInProgressError =
Class.new(StandardError)
TRANSACTION_MESSAGE =
"can't perform network calls inside a database transaction"
BATCH_SIZE =
100
RETRY_IN =
10.minutes
ACCEPTABLE_DELAY =
12.hours

Instance Method Summary collapse

Instance Method Details

#executeObject



11
12
13
14
15
# File 'app/services/ci/delete_objects_service.rb', line 11

def execute
  objects = load_next_batch

  destroy_everything(objects)
end

#remaining_batches_count(max_batch_count:) ⇒ Object



17
18
19
20
21
22
23
# File 'app/services/ci/delete_objects_service.rb', line 17

def remaining_batches_count(max_batch_count:)
  Ci::DeletedObject
    .ready_for_destruction(max_batch_count * BATCH_SIZE)
    .size
    .fdiv(BATCH_SIZE)
    .ceil
end