diff --git a/services/document-updater/app/coffee/HistoryManager.coffee b/services/document-updater/app/coffee/HistoryManager.coffee index 0e13627445..183ac268f3 100644 --- a/services/document-updater/app/coffee/HistoryManager.coffee +++ b/services/document-updater/app/coffee/HistoryManager.coffee @@ -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'} diff --git a/services/document-updater/config/settings.defaults.coffee b/services/document-updater/config/settings.defaults.coffee index e8804dfe3e..9eebe86005 100755 --- a/services/document-updater/config/settings.defaults.coffee +++ b/services/document-updater/config/settings.defaults.coffee @@ -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 diff --git a/services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee b/services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee index 4a738bd455..6cb6b1d8da 100644 --- a/services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee +++ b/services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee @@ -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)