Skip to content

Instantly share code, notes, and snippets.

@yob
Created August 24, 2009 02:26
Show Gist options
  • Select an option

  • Save yob/173609 to your computer and use it in GitHub Desktop.

Select an option

Save yob/173609 to your computer and use it in GitHub Desktop.
# a Delta indexing handler for Thinking Sphinx. By default TS rebuilds
# the delta index within the users request cycle. This is *bad* for
# speed reasons.
#
# Using this handler causes the delta indexes to be rebuilt via the
# async queue.
#
class RudeqDelta < ThinkingSphinx::Deltas::DefaultDelta
def index(model, instance = nil)
return true unless ThinkingSphinx.updates_enabled? && ThinkingSphinx.deltas_enabled?
return true if instance && !toggled(instance)
# first rebuild the delta index
RudeQueue.general_unless_dupe(:sphinx_delta, :index => delta_index_name(model))
# then remove the changed instance from the core index if necessary
if instance
RudeQueue.general_unless_dupe(:sphinx_flag_deleted, :index => core_index_name(model),
:doc_id => instance.sphinx_document_id)
end
true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment