mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Use expiresAt rather than tempCreatedAt
This commit is contained in:
parent
8b0b79bc32
commit
29ad81c134
3 changed files with 13 additions and 12 deletions
|
@ -40,7 +40,11 @@ module.exports = MongoManager =
|
||||||
v: update.v
|
v: update.v
|
||||||
}
|
}
|
||||||
if temporary
|
if temporary
|
||||||
update.tempCreatedAt = new Date()
|
seconds = 1000
|
||||||
|
minutes = 60 * seconds
|
||||||
|
hours = 60 * minutes
|
||||||
|
days = 24 * hours
|
||||||
|
update.expiresAt = new Date(Date.now() + 7 * days)
|
||||||
db.docHistory.insert update, callback
|
db.docHistory.insert update, callback
|
||||||
|
|
||||||
getDocUpdates:(doc_id, options = {}, callback = (error, updates) ->) ->
|
getDocUpdates:(doc_id, options = {}, callback = (error, updates) ->) ->
|
||||||
|
@ -120,7 +124,4 @@ module.exports = MongoManager =
|
||||||
# For finding project meta-data
|
# For finding project meta-data
|
||||||
db.projectHistoryMetaData.ensureIndex { project_id: 1 }
|
db.projectHistoryMetaData.ensureIndex { project_id: 1 }
|
||||||
# TTL index for auto deleting week old temporary ops
|
# TTL index for auto deleting week old temporary ops
|
||||||
minutes = 60
|
db.docHistory.ensureIndex { tempCreatedAt: 1 }, { expireAfterSeconds: 0 }
|
||||||
hours = 60 * minutes
|
|
||||||
days = 24 * hours
|
|
||||||
db.docHistory.ensureIndex { tempCreatedAt: 1 }, { expireAfterSeconds: 7 * days }
|
|
||||||
|
|
|
@ -250,8 +250,8 @@ describe "Appending doc ops to the history", ->
|
||||||
throw error if error?
|
throw error if error?
|
||||||
done()
|
done()
|
||||||
|
|
||||||
it "should not add a tempCreatedAt entry in the update in mongo", ->
|
it "should not add a expiresAt entry in the update in mongo", ->
|
||||||
expect(@updates[0].tempCreatedAt).to.be.undefined
|
expect(@updates[0].expiresAt).to.be.undefined
|
||||||
|
|
||||||
describe "when the project does not have versioning enabled", ->
|
describe "when the project does not have versioning enabled", ->
|
||||||
before (done) ->
|
before (done) ->
|
||||||
|
@ -270,5 +270,5 @@ describe "Appending doc ops to the history", ->
|
||||||
throw error if error?
|
throw error if error?
|
||||||
done()
|
done()
|
||||||
|
|
||||||
it "should add a tempCreatedAt entry in the update in mongo", ->
|
it "should add a expiresAt entry in the update in mongo", ->
|
||||||
expect(@updates[0].tempCreatedAt).to.exist
|
expect(@updates[0].expiresAt).to.exist
|
||||||
|
|
|
@ -111,7 +111,7 @@ describe "MongoManager", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@MongoManager.insertCompressedUpdate @project_id, @doc_id, @update, true, @callback
|
@MongoManager.insertCompressedUpdate @project_id, @doc_id, @update, true, @callback
|
||||||
|
|
||||||
it "should insert the update with a tempCreatedAt field", ->
|
it "should insert the update with a expiresAt field one week away", ->
|
||||||
@db.docHistory.insert
|
@db.docHistory.insert
|
||||||
.calledWith({
|
.calledWith({
|
||||||
project_id: ObjectId(@project_id),
|
project_id: ObjectId(@project_id),
|
||||||
|
@ -119,7 +119,7 @@ describe "MongoManager", ->
|
||||||
op: @update.op,
|
op: @update.op,
|
||||||
meta: @update.meta,
|
meta: @update.meta,
|
||||||
v: @update.v
|
v: @update.v
|
||||||
tempCreatedAt: new Date()
|
expiresAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000)
|
||||||
})
|
})
|
||||||
.should.equal true
|
.should.equal true
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ describe "MongoManager", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@MongoManager.insertCompressedUpdate @project_id, @doc_id, @update, false, @callback
|
@MongoManager.insertCompressedUpdate @project_id, @doc_id, @update, false, @callback
|
||||||
|
|
||||||
it "should insert the update with no tempCreatedAt field", ->
|
it "should insert the update with no expiresAt field", ->
|
||||||
@db.docHistory.insert
|
@db.docHistory.insert
|
||||||
.calledWith({
|
.calledWith({
|
||||||
project_id: ObjectId(@project_id),
|
project_id: ObjectId(@project_id),
|
||||||
|
|
Loading…
Reference in a new issue