Merge pull request #11287 from overleaf/bg-clear-first-op-timestamp-2

clear the first op timestamp whenever the queue is processed (2nd attempt)

GitOrigin-RevId: 0764ca6360b2a9203e5d32499213b312563a2c47
This commit is contained in:
Miguel Serrano 2023-02-09 15:20:02 +01:00 committed by Copybot
parent 25f75bbc41
commit 98cf5765e9
2 changed files with 16 additions and 1 deletions

View file

@ -234,6 +234,7 @@ _mocks.deleteAppliedDocUpdates = (project_id, updates, callback) => {
status: 'lrem',
})
multi.lrem(Keys.projectHistoryOps({ project_id }), 1, update)
multi.del(Keys.projectHistoryFirstOpTimestamp({ project_id }))
}
multi.exec(callback)
}
@ -247,7 +248,11 @@ export function destroyDocUpdatesQueue(project_id, callback) {
if (callback == null) {
callback = function () {}
}
return rclient.del(Keys.projectHistoryOps({ project_id }), callback)
return rclient.del(
Keys.projectHistoryOps({ project_id }),
Keys.projectHistoryFirstOpTimestamp({ project_id }),
callback
)
}
// iterate over keys asynchronously using redis scan (non-blocking)

View file

@ -27,6 +27,7 @@ describe('RedisManager', function () {
lrange: sinon.stub(),
lrem: sinon.stub(),
srem: sinon.stub(),
del: sinon.stub(),
}
this.rclient.multi = sinon.stub().returns(this.rclient)
this.RedisWrapper = {
@ -39,6 +40,9 @@ describe('RedisManager', function () {
projectHistoryOps({ project_id }) {
return `Project:HistoryOps:${project_id}`
},
projectHistoryFirstOpTimestamp({ project_id }) {
return `ProjectHistory:FirstOpTimestamp:{${project_id}}`
},
},
},
},
@ -132,6 +136,12 @@ describe('RedisManager', function () {
.should.equal(true)
})
it('should clear the first op timestamp', function () {
return this.rclient.del
.calledWith(`ProjectHistory:FirstOpTimestamp:{${this.project_id}}`)
.should.equal(true)
})
return it('should call the callback ', function () {
return this.callback.called.should.equal(true)
})