mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 06:05:30 -05:00
pass options through stating how long ago want to archive from and limit
This commit is contained in:
parent
70b825fd2a
commit
d3499acd7b
2 changed files with 12 additions and 7 deletions
|
@ -6,11 +6,13 @@ module.exports =
|
|||
|
||||
deactivateOldProjects: (req, res)->
|
||||
logger.log "recived request to deactivate old projects"
|
||||
InactiveProjectManager.deactivateOldProjects 10, (err)->
|
||||
numberOfProjectsToArchive = req.query.limit
|
||||
ageOfProjects = req.query.daysOld
|
||||
InactiveProjectManager.deactivateOldProjects numberOfProjectsToArchive, ageOfProjects, (err, projectsDeactivated)->
|
||||
if err?
|
||||
res.sendStatus(500)
|
||||
else
|
||||
res.sendStatus(200)
|
||||
res.send(projectsDeactivated)
|
||||
|
||||
|
||||
deactivateProject: (req, res)->
|
||||
|
|
|
@ -25,11 +25,11 @@ module.exports = InactiveProjectManager =
|
|||
return callback(err)
|
||||
ProjectUpdateHandler.markAsActive project_id, callback
|
||||
|
||||
deactivateOldProjects: (limit, callback)->
|
||||
|
||||
sixMonthsAgo = new Date() - (MILISECONDS_IN_DAY * 1)
|
||||
deactivateOldProjects: (limit = 10, daysOld = 360, callback)->
|
||||
oldProjectDate = new Date() - (MILISECONDS_IN_DAY * daysOld)
|
||||
logger.log oldProjectDate:oldProjectDate, limit:limit, daysOld:daysOld, "starting process of deactivating old projects"
|
||||
Project.find()
|
||||
.where("lastOpened").lt(sixMonthsAgo)
|
||||
.where("lastOpened").lt(oldProjectDate)
|
||||
.where("inactive").ne(true)
|
||||
.select("_id")
|
||||
.limit(limit)
|
||||
|
@ -40,7 +40,10 @@ module.exports = InactiveProjectManager =
|
|||
return (cb)->
|
||||
InactiveProjectManager.deactivateProject project._id, cb
|
||||
logger.log numberOfProjects:projects?.length, "deactivating projects"
|
||||
async.series jobs, callback
|
||||
async.series jobs, (err)->
|
||||
if err?
|
||||
logger.err err:err, "error deactivating projects"
|
||||
callback err, projects
|
||||
|
||||
|
||||
deactivateProject: (project_id, callback)->
|
||||
|
|
Loading…
Reference in a new issue