Skip to content

Commit

Permalink
fixed type of document while removing it from index; closes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
nodecarter committed Aug 14, 2014
1 parent dcc2a6e commit 1ce9bbd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/workers/indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ def defer(object_or_class)
params = { type: object_or_class.name }
self.perform_async(params)
elsif object_or_class.id?
params = { id: object_or_class.id, type: object_or_class.class.name }
params = {
id: object_or_class.id,
type: object_or_class.event_type
}
self.perform_async(params)
end
rescue Exception => e
Expand All @@ -26,7 +29,7 @@ def perform_async(options)
end

def perform(options)
id, type = options['id'], options['type']
id, type = options.with_indifferent_access[:id], options.with_indifferent_access[:type]
id.nil? ? update_class_index(type) : update_instance_index(type, id)
end

Expand All @@ -43,6 +46,7 @@ def update_instance_index(type, id)
document.update_index
rescue ActiveRecord::RecordNotFound
klass.index.remove type, id
klass.index.update_index
rescue ::RestClient::Exception, Errno::ECONNREFUSED => e
raise IndexError, e, e.backtrace
end
Expand Down

0 comments on commit 1ce9bbd

Please sign in to comment.