mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 14:03:42 -05:00
rename HistoryManager pushUncompressedHistoryOps
This commit is contained in:
parent
7ce6285e3d
commit
36407ac726
4 changed files with 10 additions and 10 deletions
|
@ -22,7 +22,7 @@ module.exports = HistoryManager =
|
||||||
return callback(error)
|
return callback(error)
|
||||||
|
|
||||||
FLUSH_EVERY_N_OPS: 100
|
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
|
if ops.length == 0
|
||||||
return callback()
|
return callback()
|
||||||
HistoryRedisManager.recordDocHasHistoryOps project_id, doc_id, ops, (error) ->
|
HistoryRedisManager.recordDocHasHistoryOps project_id, doc_id, ops, (error) ->
|
||||||
|
|
|
@ -63,7 +63,7 @@ module.exports = UpdateManager =
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
RedisManager.updateDocument doc_id, updatedDocLines, version, appliedOps, new_ranges, (error, historyOpsLength) ->
|
RedisManager.updateDocument doc_id, updatedDocLines, version, appliedOps, new_ranges, (error, historyOpsLength) ->
|
||||||
return callback(error) if error?
|
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) ->
|
lockUpdatesAndDo: (method, project_id, doc_id, args..., callback) ->
|
||||||
LockManager.getLock doc_id, (error, lockValue) ->
|
LockManager.getLock doc_id, (error, lockValue) ->
|
||||||
|
|
|
@ -40,7 +40,7 @@ describe "HistoryManager", ->
|
||||||
it "should return the callback with an error", ->
|
it "should return the callback with an error", ->
|
||||||
@callback.calledWith(new Error("track changes api return non-success code: 500")).should.equal true
|
@callback.calledWith(new Error("track changes api return non-success code: 500")).should.equal true
|
||||||
|
|
||||||
describe "pushUncompressedHistoryOps", ->
|
describe "recordAndFlushHistoryOps", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@ops = ["mock-ops"]
|
@ops = ["mock-ops"]
|
||||||
@HistoryManager.flushDocChanges = sinon.stub().callsArg(2)
|
@HistoryManager.flushDocChanges = sinon.stub().callsArg(2)
|
||||||
|
@ -48,7 +48,7 @@ describe "HistoryManager", ->
|
||||||
describe "pushing the op", ->
|
describe "pushing the op", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@HistoryRedisManager.recordDocHasHistoryOps = sinon.stub().callsArgWith(3, null)
|
@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", ->
|
it "should push the ops into redis", ->
|
||||||
@HistoryRedisManager.recordDocHasHistoryOps
|
@HistoryRedisManager.recordDocHasHistoryOps
|
||||||
|
@ -65,7 +65,7 @@ describe "HistoryManager", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@HistoryRedisManager.recordDocHasHistoryOps =
|
@HistoryRedisManager.recordDocHasHistoryOps =
|
||||||
sinon.stub().callsArgWith(3, null)
|
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", ->
|
it "should tell the track changes api to flush", ->
|
||||||
@HistoryManager.flushDocChanges
|
@HistoryManager.flushDocChanges
|
||||||
|
@ -77,7 +77,7 @@ describe "HistoryManager", ->
|
||||||
@ops = ["op1", "op2", "op3"]
|
@ops = ["op1", "op2", "op3"]
|
||||||
@HistoryRedisManager.recordDocHasHistoryOps =
|
@HistoryRedisManager.recordDocHasHistoryOps =
|
||||||
sinon.stub().callsArgWith(3, null)
|
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", ->
|
it "should tell the track changes api to flush", ->
|
||||||
@HistoryManager.flushDocChanges
|
@HistoryManager.flushDocChanges
|
||||||
|
@ -89,7 +89,7 @@ describe "HistoryManager", ->
|
||||||
@HistoryRedisManager.recordDocHasHistoryOps =
|
@HistoryRedisManager.recordDocHasHistoryOps =
|
||||||
sinon.stub().callsArgWith(3, null)
|
sinon.stub().callsArgWith(3, null)
|
||||||
@HistoryManager.flushDocChanges = sinon.stub().callsArgWith(2, @error = new Error("oops"))
|
@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", ->
|
it "should log out the error", ->
|
||||||
@logger.error
|
@logger.error
|
||||||
|
@ -104,7 +104,7 @@ describe "HistoryManager", ->
|
||||||
describe "with no ops", ->
|
describe "with no ops", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@HistoryRedisManager.recordDocHasHistoryOps = sinon.stub().callsArgWith(3, null)
|
@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", ->
|
it "should not call HistoryRedisManager.recordDocHasHistoryOps", ->
|
||||||
@HistoryRedisManager.recordDocHasHistoryOps.called.should.equal false
|
@HistoryRedisManager.recordDocHasHistoryOps.called.should.equal false
|
||||||
|
|
|
@ -166,7 +166,7 @@ describe "UpdateManager", ->
|
||||||
@ShareJsUpdateManager.applyUpdate = sinon.stub().yields(null, @updatedDocLines, @version, @appliedOps)
|
@ShareJsUpdateManager.applyUpdate = sinon.stub().yields(null, @updatedDocLines, @version, @appliedOps)
|
||||||
@RedisManager.updateDocument = sinon.stub().yields()
|
@RedisManager.updateDocument = sinon.stub().yields()
|
||||||
@RealTimeRedisManager.sendData = sinon.stub()
|
@RealTimeRedisManager.sendData = sinon.stub()
|
||||||
@HistoryManager.pushUncompressedHistoryOps = sinon.stub().callsArg(4)
|
@HistoryManager.recordAndFlushHistoryOps = sinon.stub().callsArg(4)
|
||||||
|
|
||||||
describe "normally", ->
|
describe "normally", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
@ -188,7 +188,7 @@ describe "UpdateManager", ->
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
it "should push the applied ops into the history queue", ->
|
it "should push the applied ops into the history queue", ->
|
||||||
@HistoryManager.pushUncompressedHistoryOps
|
@HistoryManager.recordAndFlushHistoryOps
|
||||||
.calledWith(@project_id, @doc_id, @appliedOps)
|
.calledWith(@project_id, @doc_id, @appliedOps)
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue