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-2.0.1 lib/searchkick/reindex_v2_job.rb
searchkick-2.0.0 lib/searchkick/reindex_v2_job.rb
searchkick-1.5.1 lib/searchkick/reindex_v2_job.rb
searchkick-1.5.0 lib/searchkick/reindex_v2_job.rb
searchkick-1.4.2 lib/searchkick/reindex_v2_job.rb
searchkick-1.4.1 lib/searchkick/reindex_v2_job.rb
searchkick-1.4.0 lib/searchkick/reindex_v2_job.rb
searchkick-1.3.6 lib/searchkick/reindex_v2_job.rb
searchkick-1.3.5 lib/searchkick/reindex_v2_job.rb
searchkick-1.3.4 lib/searchkick/reindex_v2_job.rb
searchkick-1.3.3 lib/searchkick/reindex_v2_job.rb
searchkick-1.3.2 lib/searchkick/reindex_v2_job.rb
searchkick_bharthur-0.0.2 lib/searchkick/reindex_v2_job.rb
searchkick_bharthur-0.0.1 lib/searchkick/reindex_v2_job.rb
searchkick-1.3.1 lib/searchkick/reindex_v2_job.rb
searchkick-1.3.0 lib/searchkick/reindex_v2_job.rb
searchkick-1.2.1 lib/searchkick/reindex_v2_job.rb
searchkick-1.2.0 lib/searchkick/reindex_v2_job.rb
searchkick-1.1.2 lib/searchkick/reindex_v2_job.rb
searchkick-1.1.1 lib/searchkick/reindex_v2_job.rb