Class: Users::MigrateRecordsToGhostUserInBatchesService

Inherits:
Object
  • Object
show all
Defined in:
app/services/users/migrate_records_to_ghost_user_in_batches_service.rb

Constant Summary collapse

LIMIT_SIZE =
1000

Instance Method Summary collapse

Constructor Details

#initializeMigrateRecordsToGhostUserInBatchesService

Returns a new instance of MigrateRecordsToGhostUserInBatchesService.



7
8
9
# File 'app/services/users/migrate_records_to_ghost_user_in_batches_service.rb', line 7

def initialize
  @execution_tracker = Gitlab::Utils::ExecutionTracker.new
end

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/users/migrate_records_to_ghost_user_in_batches_service.rb', line 11

def execute
  ghost_user_migrations.each do |job|
    break if execution_tracker.over_limit?

    service = Users::MigrateRecordsToGhostUserService.new(
      job.user,
      job.initiator_user,
      execution_tracker
    )
    service.execute(hard_delete: job.hard_delete)
  rescue Gitlab::Utils::ExecutionTracker::ExecutionTimeOutError
    # no-op
  rescue StandardError => e
    ::Gitlab::ErrorTracking.track_exception(e)
    reschedule(job)
  end
end