mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-30 19:00:48 +00:00
add limit parameter to flushAll
This commit is contained in:
parent
976f19f763
commit
43f51355b2
2 changed files with 12 additions and 7 deletions
|
@ -23,12 +23,16 @@ module.exports = HttpController =
|
||||||
res.send 204
|
res.send 204
|
||||||
|
|
||||||
flushAll: (req, res, next = (error) ->) ->
|
flushAll: (req, res, next = (error) ->) ->
|
||||||
logger.log "flushing all projects"
|
# limit on projects to flush or -1 for all (default)
|
||||||
UpdatesManager.flushAll (error, result) ->
|
limit = if req.query.limit? then parseInt(req.query.limit, 10) else -1
|
||||||
|
logger.log {limit: limit}, "flushing all projects"
|
||||||
|
UpdatesManager.flushAll limit, (error, result) ->
|
||||||
return next(error) if error?
|
return next(error) if error?
|
||||||
{failed, succeeded} = result
|
{failed, succeeded, all} = result
|
||||||
status = "#{succeeded.length} succeeded, #{failed.length} failed"
|
status = "#{succeeded.length} succeeded, #{failed.length} failed"
|
||||||
if failed.length > 0
|
if limit == 0
|
||||||
|
res.status(200).send "#{status}\nwould flush:\n#{all.join('\n')}\n"
|
||||||
|
else if failed.length > 0
|
||||||
logger.log {failed: failed, succeeded: succeeded}, "error flushing projects"
|
logger.log {failed: failed, succeeded: succeeded}, "error flushing projects"
|
||||||
res.status(500).send "#{status}\nfailed to flush:\n#{failed.join('\n')}\n"
|
res.status(500).send "#{status}\nfailed to flush:\n#{failed.join('\n')}\n"
|
||||||
else
|
else
|
||||||
|
|
|
@ -145,12 +145,13 @@ module.exports = UpdatesManager =
|
||||||
async.parallelLimit jobs, 5, callback
|
async.parallelLimit jobs, 5, callback
|
||||||
|
|
||||||
# flush all outstanding changes
|
# flush all outstanding changes
|
||||||
flushAll: (callback = (error, result) ->) ->
|
flushAll: (limit, callback = (error, result) ->) ->
|
||||||
RedisManager.getProjectIdsWithHistoryOps (error, project_ids) ->
|
RedisManager.getProjectIdsWithHistoryOps (error, project_ids) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
logger.log {count: project_ids?.length, project_ids: project_ids}, "found projects"
|
logger.log {count: project_ids?.length, project_ids: project_ids}, "found projects"
|
||||||
jobs = []
|
jobs = []
|
||||||
for project_id in project_ids
|
selectedProjects = if limit < 0 then project_ids else project_ids[0...limit]
|
||||||
|
for project_id in selectedProjects
|
||||||
do (project_id) ->
|
do (project_id) ->
|
||||||
jobs.push (cb) ->
|
jobs.push (cb) ->
|
||||||
UpdatesManager.processUncompressedUpdatesForProject project_id, (err) ->
|
UpdatesManager.processUncompressedUpdatesForProject project_id, (err) ->
|
||||||
|
@ -159,7 +160,7 @@ module.exports = UpdatesManager =
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
failedProjects = (x.project_id for x in result when x.failed)
|
failedProjects = (x.project_id for x in result when x.failed)
|
||||||
succeededProjects = (x.project_id for x in result when not x.failed)
|
succeededProjects = (x.project_id for x in result when not x.failed)
|
||||||
callback(null, {failed: failedProjects, succeeded: succeededProjects})
|
callback(null, {failed: failedProjects, succeeded: succeededProjects, all: project_ids})
|
||||||
|
|
||||||
getDanglingUpdates: (callback = (error, doc_ids) ->) ->
|
getDanglingUpdates: (callback = (error, doc_ids) ->) ->
|
||||||
RedisManager.getAllDocIdsWithHistoryOps (error, all_doc_ids) ->
|
RedisManager.getAllDocIdsWithHistoryOps (error, all_doc_ids) ->
|
||||||
|
|
Loading…
Reference in a new issue