Created
June 25, 2020 03:00
-
-
Save jambun/8eea4df6edf54f2856a52badbf77035f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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