|
|
@@ -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)
|