diff --git a/services/project-history/app/js/RedisManager.js b/services/project-history/app/js/RedisManager.js index 9578bad3ed..97c1c31ea2 100644 --- a/services/project-history/app/js/RedisManager.js +++ b/services/project-history/app/js/RedisManager.js @@ -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) diff --git a/services/project-history/test/unit/js/RedisManager/RedisManagerTests.js b/services/project-history/test/unit/js/RedisManager/RedisManagerTests.js index 0b4e1a6051..b63165baec 100644 --- a/services/project-history/test/unit/js/RedisManager/RedisManagerTests.js +++ b/services/project-history/test/unit/js/RedisManager/RedisManagerTests.js @@ -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) })