2014-02-12 05:23:40 -05:00
|
|
|
Project = require('../../models/Project').Project
|
|
|
|
logger = require('logger-sharelatex')
|
|
|
|
|
|
|
|
module.exports =
|
2019-05-02 10:03:48 -04:00
|
|
|
markAsUpdated : (projectId, lastUpdatedAt, lastUpdatedBy, callback = () ->)->
|
|
|
|
lastUpdatedAt ?= new Date()
|
|
|
|
|
|
|
|
conditions =
|
|
|
|
_id: projectId
|
|
|
|
lastUpdated: { $lt: lastUpdatedAt }
|
|
|
|
|
|
|
|
update = {
|
|
|
|
lastUpdated: lastUpdatedAt or (new Date()).getTime()
|
|
|
|
lastUpdatedBy: lastUpdatedBy
|
|
|
|
}
|
|
|
|
Project.update conditions, update, {}, callback
|
2015-08-13 17:40:28 -04:00
|
|
|
|
|
|
|
markAsOpened : (project_id, callback)->
|
|
|
|
conditions = {_id:project_id}
|
|
|
|
update = {lastOpened:Date.now()}
|
2018-09-13 09:00:30 -04:00
|
|
|
Project.update conditions, update, {}, (err)->
|
|
|
|
if callback?
|
|
|
|
callback()
|
2015-08-13 17:40:28 -04:00
|
|
|
|
|
|
|
markAsInactive: (project_id, callback)->
|
|
|
|
conditions = {_id:project_id}
|
2015-08-19 06:54:30 -04:00
|
|
|
update = {active:false}
|
2018-09-13 09:00:30 -04:00
|
|
|
Project.update conditions, update, {}, (err)->
|
|
|
|
if callback?
|
|
|
|
callback()
|
2015-08-13 17:40:28 -04:00
|
|
|
|
|
|
|
markAsActive: (project_id, callback)->
|
|
|
|
conditions = {_id:project_id}
|
2015-08-19 06:54:30 -04:00
|
|
|
update = {active:true}
|
2018-09-13 09:00:30 -04:00
|
|
|
Project.update conditions, update, {}, (err)->
|
|
|
|
if callback?
|
2019-05-02 10:03:48 -04:00
|
|
|
callback()
|