mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
changed inactive to active as its more effienct query in mongo
This commit is contained in:
parent
d3499acd7b
commit
50fc886c94
5 changed files with 12 additions and 12 deletions
|
@ -10,13 +10,13 @@ MILISECONDS_IN_DAY = 86400000
|
|||
module.exports = InactiveProjectManager =
|
||||
|
||||
reactivateProjectIfRequired: (project_id, callback)->
|
||||
ProjectGetter.getProject project_id, {inactive:true}, (err, project)->
|
||||
ProjectGetter.getProject project_id, {active:true}, (err, project)->
|
||||
if err?
|
||||
logger.err err:err, project_id:project_id, "error getting project"
|
||||
return callback(err)
|
||||
logger.log project_id:project_id, inactive:project.inactive, "seeing if need to reactivate project"
|
||||
logger.log project_id:project_id, active:project.active, "seeing if need to reactivate project"
|
||||
|
||||
if !project.inactive
|
||||
if project.active
|
||||
return callback()
|
||||
|
||||
DocstoreManager.unarchiveProject project_id, (err)->
|
||||
|
@ -30,7 +30,7 @@ module.exports = InactiveProjectManager =
|
|||
logger.log oldProjectDate:oldProjectDate, limit:limit, daysOld:daysOld, "starting process of deactivating old projects"
|
||||
Project.find()
|
||||
.where("lastOpened").lt(oldProjectDate)
|
||||
.where("inactive").ne(true)
|
||||
.where("active").equals(true)
|
||||
.select("_id")
|
||||
.limit(limit)
|
||||
.exec (err, projects)->
|
||||
|
|
|
@ -19,14 +19,14 @@ module.exports =
|
|||
|
||||
markAsInactive: (project_id, callback)->
|
||||
conditions = {_id:project_id}
|
||||
update = {inactive:true}
|
||||
update = {active:false}
|
||||
Project.update conditions, update, {}, (err)->
|
||||
if callback?
|
||||
callback()
|
||||
|
||||
markAsActive: (project_id, callback)->
|
||||
conditions = {_id:project_id}
|
||||
update = { $unset: { inactive: true }}
|
||||
update = {active:true}
|
||||
Project.update conditions, update, {}, (err)->
|
||||
if callback?
|
||||
callback()
|
|
@ -18,7 +18,7 @@ ProjectSchema = new Schema
|
|||
name : {type:String, default:'new project'}
|
||||
lastUpdated : {type:Date, default: () -> new Date()}
|
||||
lastOpened : {type:Date}
|
||||
inactive : { type: Boolean }
|
||||
active : { type: Boolean, default: true }
|
||||
owner_ref : {type:ObjectId, ref:'User'}
|
||||
collaberator_refs : [ type:ObjectId, ref:'User' ]
|
||||
readOnly_refs : [ type:ObjectId, ref:'User' ]
|
||||
|
|
|
@ -33,7 +33,7 @@ describe "InactiveProjectManager", ->
|
|||
describe "reactivateProjectIfRequired", ->
|
||||
|
||||
beforeEach ->
|
||||
@project = {inactive:true}
|
||||
@project = {active:false}
|
||||
@ProjectGetter.getProject.callsArgWith(2, null, @project)
|
||||
@ProjectUpdateHandler.markAsActive.callsArgWith(1)
|
||||
|
||||
|
@ -53,8 +53,8 @@ describe "InactiveProjectManager", ->
|
|||
done()
|
||||
|
||||
|
||||
it "should not call unarchiveProject if it is not inactive", (done)->
|
||||
delete @project.inactive
|
||||
it "should not call unarchiveProject if it is active", (done)->
|
||||
@project.active = true
|
||||
@DocstoreManager.unarchiveProject.callsArgWith(1)
|
||||
@InactiveProjectManager.reactivateProjectIfRequired @project_id, (err)=>
|
||||
@DocstoreManager.unarchiveProject.calledWith(@project_id).should.equal false
|
||||
|
|
|
@ -42,7 +42,7 @@ describe 'ProjectUpdateHandler', ->
|
|||
@handler.markAsInactive project_id, (err)=>
|
||||
args = @ProjectModel.update.args[0]
|
||||
args[0]._id.should.equal project_id
|
||||
args[1].inactive.should.equal true
|
||||
args[1].active.should.equal false
|
||||
done()
|
||||
|
||||
describe "markAsActive", ->
|
||||
|
@ -51,7 +51,7 @@ describe 'ProjectUpdateHandler', ->
|
|||
@handler.markAsActive project_id, (err)=>
|
||||
args = @ProjectModel.update.args[0]
|
||||
args[0]._id.should.equal project_id
|
||||
args[1]["$unset"].inactive.should.equal true
|
||||
args[1].active.should.equal true
|
||||
done()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue