mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #8802 from overleaf/bg-reset-last-updated-in-migration
[web] reset last updated date in history migration GitOrigin-RevId: 3d06eadf7d1dfb9b92a529d68de68f59370ab5de
This commit is contained in:
parent
e32d1dbdd6
commit
12bd1d49e7
1 changed files with 25 additions and 1 deletions
|
@ -13,8 +13,9 @@
|
|||
*/
|
||||
const { Project } = require('../../models/Project')
|
||||
const logger = require('@overleaf/logger')
|
||||
const { promisifyAll } = require('../../util/promises')
|
||||
|
||||
module.exports = {
|
||||
const ProjectUpdateHandler = {
|
||||
markAsUpdated(projectId, lastUpdatedAt, lastUpdatedBy, callback) {
|
||||
if (callback == null) {
|
||||
callback = function () {}
|
||||
|
@ -35,6 +36,26 @@ module.exports = {
|
|||
return Project.updateOne(conditions, update, {}, callback)
|
||||
},
|
||||
|
||||
// like markAsUpdated but allows lastUpdatedAt to be reset to earlier time
|
||||
resetUpdated(projectId, lastUpdatedAt, lastUpdatedBy, callback) {
|
||||
if (callback == null) {
|
||||
callback = function () {}
|
||||
}
|
||||
if (lastUpdatedAt == null) {
|
||||
lastUpdatedAt = new Date()
|
||||
}
|
||||
|
||||
const conditions = {
|
||||
_id: projectId,
|
||||
}
|
||||
|
||||
const update = {
|
||||
lastUpdated: lastUpdatedAt || new Date().getTime(),
|
||||
lastUpdatedBy,
|
||||
}
|
||||
return Project.updateOne(conditions, update, {}, callback)
|
||||
},
|
||||
|
||||
markAsOpened(project_id, callback) {
|
||||
const conditions = { _id: project_id }
|
||||
const update = { lastOpened: Date.now() }
|
||||
|
@ -65,3 +86,6 @@ module.exports = {
|
|||
})
|
||||
},
|
||||
}
|
||||
|
||||
ProjectUpdateHandler.promises = promisifyAll(ProjectUpdateHandler)
|
||||
module.exports = ProjectUpdateHandler
|
||||
|
|
Loading…
Reference in a new issue