2019-05-29 05:21:06 -04:00
|
|
|
/* eslint-disable
|
|
|
|
camelcase,
|
2020-12-15 05:23:54 -05:00
|
|
|
node/handle-callback-err,
|
2019-05-29 05:21:06 -04:00
|
|
|
no-unused-vars,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
|
|
|
const { Project } = require('../../models/Project')
|
|
|
|
const logger = require('logger-sharelatex')
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
markAsUpdated(projectId, lastUpdatedAt, lastUpdatedBy, callback) {
|
|
|
|
if (callback == null) {
|
2021-04-14 09:17:21 -04:00
|
|
|
callback = function () {}
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
if (lastUpdatedAt == null) {
|
|
|
|
lastUpdatedAt = new Date()
|
|
|
|
}
|
|
|
|
|
|
|
|
const conditions = {
|
|
|
|
_id: projectId,
|
2021-04-27 03:52:58 -04:00
|
|
|
lastUpdated: { $lt: lastUpdatedAt },
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
const update = {
|
|
|
|
lastUpdated: lastUpdatedAt || new Date().getTime(),
|
2021-04-27 03:52:58 -04:00
|
|
|
lastUpdatedBy,
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|
2020-11-03 04:19:05 -05:00
|
|
|
return Project.updateOne(conditions, update, {}, callback)
|
2019-05-29 05:21:06 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
markAsOpened(project_id, callback) {
|
|
|
|
const conditions = { _id: project_id }
|
|
|
|
const update = { lastOpened: Date.now() }
|
2021-04-14 09:17:21 -04:00
|
|
|
return Project.updateOne(conditions, update, {}, function (err) {
|
2019-05-29 05:21:06 -04:00
|
|
|
if (callback != null) {
|
|
|
|
return callback()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
markAsInactive(project_id, callback) {
|
|
|
|
const conditions = { _id: project_id }
|
|
|
|
const update = { active: false }
|
2021-04-14 09:17:21 -04:00
|
|
|
return Project.updateOne(conditions, update, {}, function (err) {
|
2019-05-29 05:21:06 -04:00
|
|
|
if (callback != null) {
|
|
|
|
return callback()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
markAsActive(project_id, callback) {
|
|
|
|
const conditions = { _id: project_id }
|
|
|
|
const update = { active: true }
|
2021-04-14 09:17:21 -04:00
|
|
|
return Project.updateOne(conditions, update, {}, function (err) {
|
2019-05-29 05:21:06 -04:00
|
|
|
if (callback != null) {
|
|
|
|
return callback()
|
|
|
|
}
|
|
|
|
})
|
2021-04-27 03:52:58 -04:00
|
|
|
},
|
2019-05-29 05:21:06 -04:00
|
|
|
}
|