Class: Dionysus::Consumer::SyncedData::AssignColumnsFromSyncedDataJob
- Inherits:
-
Object
- Object
- Dionysus::Consumer::SyncedData::AssignColumnsFromSyncedDataJob
- Includes:
- Sidekiq::Worker
- Defined in:
- lib/dionysus/consumer/synced_data/assign_columns_from_synced_data_job.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.enqueue(model_klass, columns, batch_size: 1000) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/dionysus/consumer/synced_data/assign_columns_from_synced_data_job.rb', line 8 def self.enqueue(model_klass, columns, batch_size: 1000) primary_key = model_klass.primary_key model_klass.select(:id).find_in_batches(batch_size: batch_size).with_index do |records, index| Dionysus.logger.info "[AssignColumnsFromSyncedDataJob] enqueue batch: #{index}" model_name = model_klass.model_name.to_s ids = records.map { |r| r.public_send(primary_key) } set(queue: Dionysus::Consumer.configuration.sidekiq_queue) .perform_async(model_name, ids, columns) end end |
Instance Method Details
#perform(model_name, ids, columns) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/dionysus/consumer/synced_data/assign_columns_from_synced_data_job.rb', line 20 def perform(model_name, ids, columns) model_klass = model_name.constantize collection = model_klass.where(model_klass.primary_key => ids) Dionysus::Consumer::SyncedData::AssignColumnsFromSyncedData.new.call(collection, columns) end |