Sha256: 44a2230a68a540864da182b074e99b78dac9b0c177c62ccb2dd394f421bc5714
Contents?: true
Size: 1003 Bytes
Versions: 2
Compression:
Stored size: 1003 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 def perform(klass, id) model = klass.constantize record = begin model.find(id) 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 index = model.searchkick_index if !record || !record.should_index? # hacky record ||= model.new record.id = id begin index.remove record rescue Elasticsearch::Transport::Transport::Errors::NotFound # do nothing end else index.store record end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
searchkick-2.2.1 | lib/searchkick/reindex_v2_job.rb |
searchkick-2.2.0 | lib/searchkick/reindex_v2_job.rb |