mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
improve performance for migrating large dochistory collections
This commit is contained in:
parent
f764f77b30
commit
39e10c88c1
1 changed files with 18 additions and 4 deletions
|
@ -113,10 +113,20 @@ exports.migrate = (client, done = ->)->
|
|||
console.log "completed #{count}/#{totalDocCount} processed=#{processedFraction.toFixed(2)} remaining=#{remainingFraction.toFixed(2)} elapsed=#{(t-t0)/1000} est Finish=#{estFinishTime}"
|
||||
interval = setInterval printProgress, 3*1000
|
||||
|
||||
jobs = _.map _.filter(ids, (id) -> not finished_docs[id]), (id)->
|
||||
return (cb)->
|
||||
processNext(id, cb)
|
||||
async.series jobs, (err)->
|
||||
nextId = null
|
||||
|
||||
testFn = () ->
|
||||
return false if needToExit
|
||||
id = ids.shift()
|
||||
while id? and finished_docs[id] # skip finished
|
||||
id = ids.shift()
|
||||
nextId = id
|
||||
return nextId?
|
||||
|
||||
executeFn = (cb) ->
|
||||
processNext nextId, cb
|
||||
|
||||
async.whilst testFn, executeFn, (err)->
|
||||
if err?
|
||||
console.error err, "at end of jobs"
|
||||
else
|
||||
|
@ -127,6 +137,10 @@ exports.migrate = (client, done = ->)->
|
|||
exports.rollback = (client, done)->
|
||||
done()
|
||||
|
||||
# process.nextTick () ->
|
||||
# exports.migrate () ->
|
||||
# console.log "done"
|
||||
|
||||
DAYS = 24 * 3600 * 1000 # one day in milliseconds
|
||||
|
||||
# copied from track-changes/app/coffee/PackManager.coffee
|
||||
|
|
Loading…
Reference in a new issue