Sha256: b049fa31011979378ad690fdf926224e36960cc0c150230a810e141b7b8d632e

Contents?: true

Size: 568 Bytes

Versions: 5

Compression:

Stored size: 568 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 or !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

5 entries across 5 versions & 1 rubygems

Version Path
searchkick-0.8.7 lib/searchkick/reindex_v2_job.rb
searchkick-0.8.6 lib/searchkick/reindex_v2_job.rb
searchkick-0.8.5 lib/searchkick/reindex_v2_job.rb
searchkick-0.8.4 lib/searchkick/reindex_v2_job.rb
searchkick-0.8.3 lib/searchkick/reindex_v2_job.rb