mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
add dryRun option to flush all projects
This commit is contained in:
parent
d5d1736a5e
commit
daca83a057
2 changed files with 10 additions and 6 deletions
|
@ -184,9 +184,11 @@ module.exports = HttpController =
|
|||
|
||||
flushAllProjects: (req, res, next = (error)-> )->
|
||||
res.setTimeout(5 * 60 * 1000)
|
||||
limit = req.query.limit || 1000
|
||||
concurrency = req.query.concurrency || 5
|
||||
ProjectFlusher.flushAllProjects limit, concurrency, (err, project_ids)->
|
||||
options =
|
||||
limit : req.query.limit || 1000
|
||||
concurrency : req.query.concurrency || 5
|
||||
dryRun : req.query.dryRun || false
|
||||
ProjectFlusher.flushAllProjects options, (err, project_ids)->
|
||||
if err?
|
||||
logger.err err:err, "error bulk flushing projects"
|
||||
res.send 500
|
||||
|
|
|
@ -45,16 +45,18 @@ ProjectFlusher =
|
|||
m[1]
|
||||
return ids
|
||||
|
||||
flushAllProjects: (limit, concurrency = 5, callback)->
|
||||
ProjectFlusher._getKeys docUpdaterKeys.docsInProject({project_id:"*"}), limit, (error, project_keys) ->
|
||||
flushAllProjects: (options, callback)->
|
||||
ProjectFlusher._getKeys docUpdaterKeys.docsInProject({project_id:"*"}), options.limit, (error, project_keys) ->
|
||||
if error?
|
||||
logger.err err:error, "error getting keys for flushing"
|
||||
return callback(error)
|
||||
project_ids = ProjectFlusher._extractIds(project_keys)
|
||||
if options.dryRun
|
||||
return callback(null, project_ids)
|
||||
jobs = _.map project_ids, (project_id)->
|
||||
return (cb)->
|
||||
ProjectManager.flushAndDeleteProjectWithLocks project_id, cb
|
||||
async.parallelLimit jobs, concurrency, (error)->
|
||||
async.parallelLimit jobs, options.concurrency, (error)->
|
||||
return callback(error, project_ids)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue