mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
increase flush threshold to 100 ops
This commit is contained in:
parent
fdf5e8e0b8
commit
7ce6285e3d
2 changed files with 7 additions and 7 deletions
|
@ -21,17 +21,17 @@ module.exports = HistoryManager =
|
|||
error = new Error("track changes api returned a failure status code: #{res.statusCode}")
|
||||
return callback(error)
|
||||
|
||||
FLUSH_EVERY_N_OPS: 50
|
||||
FLUSH_EVERY_N_OPS: 100
|
||||
pushUncompressedHistoryOps: (project_id, doc_id, ops = [], length, callback = (error) ->) ->
|
||||
if ops.length == 0
|
||||
return callback()
|
||||
HistoryRedisManager.recordDocHasHistoryOps project_id, doc_id, ops, (error) ->
|
||||
return callback(error) if error?
|
||||
return callback() if not length? # don't flush unless we know the length
|
||||
# We want to flush every 50 ops, i.e. 50, 100, 150, etc
|
||||
# Find out which 'block' (i.e. 0-49, 50-99) we were in before and after pushing these
|
||||
# ops. If we've changed, then we've gone over a multiple of 50 and should flush.
|
||||
# (Most of the time, we will only hit 50 and then flushing will put us back to 0)
|
||||
# We want to flush every 100 ops, i.e. 100, 200, 300, etc
|
||||
# Find out which 'block' (i.e. 0-99, 100-199) we were in before and after pushing these
|
||||
# ops. If we've changed, then we've gone over a multiple of 100 and should flush.
|
||||
# (Most of the time, we will only hit 100 and then flushing will put us back to 0)
|
||||
previousLength = length - ops.length
|
||||
prevBlock = Math.floor(previousLength / HistoryManager.FLUSH_EVERY_N_OPS)
|
||||
newBlock = Math.floor(length / HistoryManager.FLUSH_EVERY_N_OPS)
|
||||
|
|
|
@ -207,7 +207,7 @@ describe "Applying updates to a doc", ->
|
|||
before (done) ->
|
||||
[@project_id, @doc_id] = [DocUpdaterClient.randomId(), DocUpdaterClient.randomId()]
|
||||
updates = []
|
||||
for v in [0..99] # Should flush after 50 ops
|
||||
for v in [0..199] # Should flush after 100 ops
|
||||
updates.push
|
||||
doc_id: @doc_id,
|
||||
op: [i: v.toString(), p: 0]
|
||||
|
@ -219,7 +219,7 @@ describe "Applying updates to a doc", ->
|
|||
|
||||
# Send updates in chunks to causes multiple flushes
|
||||
actions = []
|
||||
for i in [0..9]
|
||||
for i in [0..19]
|
||||
do (i) =>
|
||||
actions.push (cb) =>
|
||||
DocUpdaterClient.sendUpdates @project_id, @doc_id, updates.slice(i*10, (i+1)*10), cb
|
||||
|
|
Loading…
Reference in a new issue