Class: MultipleMan::AsyncModelPublisher
- Inherits:
-
ModelPublisher
- Object
- ModelPublisher
- MultipleMan::AsyncModelPublisher
- Defined in:
- lib/multiple_man_sidekiq/async_model_publisher.rb
Instance Method Summary collapse
Instance Method Details
#publish(records, operation = :create) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/multiple_man_sidekiq/async_model_publisher.rb', line 4 def publish(records, operation=:create) return unless MultipleMan.configuration.enabled if records.respond_to?(:pluck) return unless records.any? ids = records.pluck(:id) klass = records.first.class.name else return if records.nil? ids = [records.id] klass = records.class.name end # Split jobs into parts so sidekiq doesn't need to deal with enormous seed jobs. ids.each_slice(1000) do |ids| ModelPublisherJob.perform_async(klass, ids, , operation) end end |