Class: Ci::DeleteObjectsService
- Inherits:
-
Object
- Object
- Ci::DeleteObjectsService
- 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 Attribute Summary collapse
-
#batch_size ⇒ Object
readonly
Returns the value of attribute batch_size.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(batch_size: BATCH_SIZE) ⇒ DeleteObjectsService
constructor
A new instance of DeleteObjectsService.
- #remaining_batches_count(max_batch_count:) ⇒ Object
Constructor Details
#initialize(batch_size: BATCH_SIZE) ⇒ DeleteObjectsService
Returns a new instance of DeleteObjectsService.
13 14 15 |
# File 'app/services/ci/delete_objects_service.rb', line 13 def initialize(batch_size: BATCH_SIZE) @batch_size = batch_size end |
Instance Attribute Details
#batch_size ⇒ Object (readonly)
Returns the value of attribute batch_size.
11 12 13 |
# File 'app/services/ci/delete_objects_service.rb', line 11 def batch_size @batch_size end |
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 |
# File 'app/services/ci/delete_objects_service.rb', line 17 def execute objects = load_next_batch destroy_everything(objects) end |
#remaining_batches_count(max_batch_count:) ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/services/ci/delete_objects_service.rb', line 23 def remaining_batches_count(max_batch_count:) Ci::DeletedObject .ready_for_destruction(max_batch_count * batch_size) .size .fdiv(batch_size) .ceil end |