diff --git a/services/document-updater/app/coffee/HttpController.coffee b/services/document-updater/app/coffee/HttpController.coffee index 5a5c248ee9..54a69deae9 100644 --- a/services/document-updater/app/coffee/HttpController.coffee +++ b/services/document-updater/app/coffee/HttpController.coffee @@ -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 diff --git a/services/document-updater/app/coffee/ProjectFlusher.coffee b/services/document-updater/app/coffee/ProjectFlusher.coffee index b6ef3d77ca..fabc334930 100644 --- a/services/document-updater/app/coffee/ProjectFlusher.coffee +++ b/services/document-updater/app/coffee/ProjectFlusher.coffee @@ -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)