diff --git a/services/document-updater/app/coffee/HistoryManager.coffee b/services/document-updater/app/coffee/HistoryManager.coffee index 17b77a00e6..9f78b5af4b 100644 --- a/services/document-updater/app/coffee/HistoryManager.coffee +++ b/services/document-updater/app/coffee/HistoryManager.coffee @@ -22,7 +22,7 @@ module.exports = HistoryManager = return callback(error) FLUSH_EVERY_N_OPS: 100 - pushUncompressedHistoryOps: (project_id, doc_id, ops = [], length, callback = (error) ->) -> + recordAndFlushHistoryOps: (project_id, doc_id, ops = [], length, callback = (error) ->) -> if ops.length == 0 return callback() HistoryRedisManager.recordDocHasHistoryOps project_id, doc_id, ops, (error) -> diff --git a/services/document-updater/app/coffee/UpdateManager.coffee b/services/document-updater/app/coffee/UpdateManager.coffee index b903f6615f..269b16ee67 100644 --- a/services/document-updater/app/coffee/UpdateManager.coffee +++ b/services/document-updater/app/coffee/UpdateManager.coffee @@ -63,7 +63,7 @@ module.exports = UpdateManager = return callback(error) if error? RedisManager.updateDocument doc_id, updatedDocLines, version, appliedOps, new_ranges, (error, historyOpsLength) -> return callback(error) if error? - HistoryManager.pushUncompressedHistoryOps project_id, doc_id, appliedOps, historyOpsLength, callback + HistoryManager.recordAndFlushHistoryOps project_id, doc_id, appliedOps, historyOpsLength, callback lockUpdatesAndDo: (method, project_id, doc_id, args..., callback) -> LockManager.getLock doc_id, (error, lockValue) -> diff --git a/services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee b/services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee index b41c9b9f7a..37e35ca285 100644 --- a/services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee +++ b/services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee @@ -40,7 +40,7 @@ describe "HistoryManager", -> it "should return the callback with an error", -> @callback.calledWith(new Error("track changes api return non-success code: 500")).should.equal true - describe "pushUncompressedHistoryOps", -> + describe "recordAndFlushHistoryOps", -> beforeEach -> @ops = ["mock-ops"] @HistoryManager.flushDocChanges = sinon.stub().callsArg(2) @@ -48,7 +48,7 @@ describe "HistoryManager", -> describe "pushing the op", -> beforeEach -> @HistoryRedisManager.recordDocHasHistoryOps = sinon.stub().callsArgWith(3, null) - @HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, 1, @callback + @HistoryManager.recordAndFlushHistoryOps @project_id, @doc_id, @ops, 1, @callback it "should push the ops into redis", -> @HistoryRedisManager.recordDocHasHistoryOps @@ -65,7 +65,7 @@ describe "HistoryManager", -> beforeEach -> @HistoryRedisManager.recordDocHasHistoryOps = sinon.stub().callsArgWith(3, null) - @HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, 2 * @HistoryManager.FLUSH_EVERY_N_OPS,@callback + @HistoryManager.recordAndFlushHistoryOps @project_id, @doc_id, @ops, 2 * @HistoryManager.FLUSH_EVERY_N_OPS,@callback it "should tell the track changes api to flush", -> @HistoryManager.flushDocChanges @@ -77,7 +77,7 @@ describe "HistoryManager", -> @ops = ["op1", "op2", "op3"] @HistoryRedisManager.recordDocHasHistoryOps = sinon.stub().callsArgWith(3, null) - @HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, 2 * @HistoryManager.FLUSH_EVERY_N_OPS + 1, @callback + @HistoryManager.recordAndFlushHistoryOps @project_id, @doc_id, @ops, 2 * @HistoryManager.FLUSH_EVERY_N_OPS + 1, @callback it "should tell the track changes api to flush", -> @HistoryManager.flushDocChanges @@ -89,7 +89,7 @@ describe "HistoryManager", -> @HistoryRedisManager.recordDocHasHistoryOps = sinon.stub().callsArgWith(3, null) @HistoryManager.flushDocChanges = sinon.stub().callsArgWith(2, @error = new Error("oops")) - @HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, 2 * @HistoryManager.FLUSH_EVERY_N_OPS, @callback + @HistoryManager.recordAndFlushHistoryOps @project_id, @doc_id, @ops, 2 * @HistoryManager.FLUSH_EVERY_N_OPS, @callback it "should log out the error", -> @logger.error @@ -104,7 +104,7 @@ describe "HistoryManager", -> describe "with no ops", -> beforeEach -> @HistoryRedisManager.recordDocHasHistoryOps = sinon.stub().callsArgWith(3, null) - @HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, [], 1, @callback + @HistoryManager.recordAndFlushHistoryOps @project_id, @doc_id, [], 1, @callback it "should not call HistoryRedisManager.recordDocHasHistoryOps", -> @HistoryRedisManager.recordDocHasHistoryOps.called.should.equal false diff --git a/services/document-updater/test/unit/coffee/UpdateManager/UpdateManagerTests.coffee b/services/document-updater/test/unit/coffee/UpdateManager/UpdateManagerTests.coffee index 57bd9166d1..2de6e93e44 100644 --- a/services/document-updater/test/unit/coffee/UpdateManager/UpdateManagerTests.coffee +++ b/services/document-updater/test/unit/coffee/UpdateManager/UpdateManagerTests.coffee @@ -166,7 +166,7 @@ describe "UpdateManager", -> @ShareJsUpdateManager.applyUpdate = sinon.stub().yields(null, @updatedDocLines, @version, @appliedOps) @RedisManager.updateDocument = sinon.stub().yields() @RealTimeRedisManager.sendData = sinon.stub() - @HistoryManager.pushUncompressedHistoryOps = sinon.stub().callsArg(4) + @HistoryManager.recordAndFlushHistoryOps = sinon.stub().callsArg(4) describe "normally", -> beforeEach -> @@ -188,7 +188,7 @@ describe "UpdateManager", -> .should.equal true it "should push the applied ops into the history queue", -> - @HistoryManager.pushUncompressedHistoryOps + @HistoryManager.recordAndFlushHistoryOps .calledWith(@project_id, @doc_id, @appliedOps) .should.equal true