Class: OnlineMigrations::DataMigrations::BackfillCallRecordRecordingSource

Inherits:
OnlineMigrations::DataMigration
  • Object
show all
Defined in:
lib/online_migrations/data_migrations/backfill_call_record_recording_source.rb

Overview

Backfill recording_source = 'switchvox' for existing CallRecords with NULL
This ensures the recording source filter works correctly for both sources.

Constant Summary collapse

BATCH_SIZE =

Batch size.

5_000

Instance Method Summary collapse

Instance Method Details

#collectionActiveRecord::Batches::BatchEnumerator

Returns batches of CallRecords missing a recording_source.

Returns:

  • (ActiveRecord::Batches::BatchEnumerator)

    batches of CallRecords missing a recording_source



12
13
14
# File 'lib/online_migrations/data_migrations/backfill_call_record_recording_source.rb', line 12

def collection
  CallRecord.where(recording_source: nil).in_batches(of: BATCH_SIZE)
end

#countInteger

Returns number of CallRecords missing a recording_source.

Returns:

  • (Integer)

    number of CallRecords missing a recording_source



22
23
24
# File 'lib/online_migrations/data_migrations/backfill_call_record_recording_source.rb', line 22

def count
  CallRecord.where(recording_source: nil).count
end

#process(call_records) ⇒ Integer

Returns number of rows updated.

Returns:

  • (Integer)

    number of rows updated



17
18
19
# File 'lib/online_migrations/data_migrations/backfill_call_record_recording_source.rb', line 17

def process(call_records)
  call_records.update_all(recording_source: 'switchvox')
end