Skip to content

Instantly share code, notes, and snippets.

@jambun
Created June 25, 2020 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jambun/8eea4df6edf54f2856a52badbf77035f to your computer and use it in GitHub Desktop.
Save jambun/8eea4df6edf54f2856a52badbf77035f to your computer and use it in GitHub Desktop.
RealtimeIndexing.class_eval do
def self.disable(&block)
begin
Thread.current[:realtime_indexing_disabled] = true
block.call
ensure
DB.after_commit do
Thread.current[:realtime_indexing_disabled] = false
end
end
end
def self.record_update(target, uri)
unless Thread.current[:realtime_indexing_disabled]
longpolling.record_update(:record => target, :uri => uri)
end
end
def self.record_delete(uri)
unless Thread.current[:realtime_indexing_disabled]
longpolling.record_update(:record => :deleted, :uri => uri)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment