Sha256: 31631974adba95a5e38871707bd2cfa560a17a55141d38d6809304031eac85e3

Contents?: true

Size: 567 Bytes

Versions: 25

Compression:

Stored size: 567 Bytes

Contents

module Searchkick
  class ReindexV2Job < ActiveJob::Base
    queue_as :searchkick

    def perform(klass, id)
      model = klass.constantize
      record = model.find(id) rescue nil # TODO fix lazy coding
      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

25 entries across 25 versions & 2 rubygems

Version Path
searchkick-1.1.0 lib/searchkick/reindex_v2_job.rb
searchkick-1.0.3 lib/searchkick/reindex_v2_job.rb
searchkick-1.0.2 lib/searchkick/reindex_v2_job.rb
searchkick-1.0.1 lib/searchkick/reindex_v2_job.rb
searchkick-1.0.0 lib/searchkick/reindex_v2_job.rb