Sha256: b0875d674b2ebdf66c2c2da28975d617af30ae02fd19275742802624a5b5b9ea
Contents?: true
Size: 951 Bytes
Versions: 2
Compression:
Stored size: 951 Bytes
Contents
module Searchkick class ReindexV2Job < ActiveJob::Base RECORD_NOT_FOUND_CLASSES = [ "ActiveRecord::RecordNotFound", "Mongoid::Errors::DocumentNotFound", "NoBrainer::Error::DocumentNotFound", "Cequel::Record::RecordNotFound" ] queue_as { Searchkick.queue_name } def perform(klass, id, method_name = nil) model = klass.constantize record = begin if model.respond_to?(:unscoped) model.unscoped.find(id) else model.find(id) end rescue => e # check by name rather than rescue directly so we don't need # to determine which classes are defined raise e unless RECORD_NOT_FOUND_CLASSES.include?(e.class.name) nil end unless record record = model.new record.id = id end RecordIndexer.new(record).reindex(method_name, mode: :inline) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
searchkick-3.1.1 | lib/searchkick/reindex_v2_job.rb |
searchkick-3.1.0 | lib/searchkick/reindex_v2_job.rb |