mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
add setting so that double flush is the default
can be disabled to stop flushing to track-changes
This commit is contained in:
parent
4f6583bbf2
commit
ad19fee667
3 changed files with 16 additions and 2 deletions
|
@ -16,7 +16,7 @@ module.exports = HistoryManager =
|
|||
if err?
|
||||
logger.warn {err, doc_id}, "error getting history type"
|
||||
# if there's an error continue and flush to track-changes for safety
|
||||
if projectHistoryType is "project-history"
|
||||
if Settings.disableDoubleFlush and projectHistoryType is "project-history"
|
||||
logger.debug {doc_id, projectHistoryType}, "skipping track-changes flush"
|
||||
else
|
||||
metrics.inc 'history-flush', 1, { status: 'track-changes'}
|
||||
|
|
|
@ -93,3 +93,5 @@ module.exports =
|
|||
continuousBackgroundFlush: process.env['CONTINUOUS_BACKGROUND_FLUSH'] or false
|
||||
|
||||
smoothingOffset: process.env['SMOOTHING_OFFSET'] or 1000 # milliseconds
|
||||
|
||||
disableDoubleFlush: process.env['DISABLE_DOUBLE_FLUSH'] or false # don't flush track-changes for projects using project-history
|
||||
|
|
|
@ -39,16 +39,28 @@ describe "HistoryManager", ->
|
|||
.calledWith("#{@Settings.apis.trackchanges.url}/project/#{@project_id}/doc/#{@doc_id}/flush")
|
||||
.should.equal true
|
||||
|
||||
describe "when the project uses project history", ->
|
||||
describe "when the project uses project history and double flush is not disabled", ->
|
||||
beforeEach ->
|
||||
@RedisManager.getHistoryType = sinon.stub().yields(null, 'project-history')
|
||||
@HistoryManager.flushDocChangesAsync @project_id, @doc_id
|
||||
|
||||
it "should send a request to the track changes api", ->
|
||||
@request.post
|
||||
.called
|
||||
.should.equal true
|
||||
|
||||
describe "when the project uses project history and double flush is disabled", ->
|
||||
beforeEach ->
|
||||
@Settings.disableDoubleFlush = true
|
||||
@RedisManager.getHistoryType = sinon.stub().yields(null, 'project-history')
|
||||
@HistoryManager.flushDocChangesAsync @project_id, @doc_id
|
||||
|
||||
it "should not send a request to the track changes api", ->
|
||||
@request.post
|
||||
.called
|
||||
.should.equal false
|
||||
|
||||
|
||||
describe "flushProjectChangesAsync", ->
|
||||
beforeEach ->
|
||||
@request.post = sinon.stub().callsArgWith(1, null, statusCode: 204)
|
||||
|
|
Loading…
Reference in a new issue