Просмотр исходного кода

Revert "Record project notification timestamp in Redis on applyUpdate (#29509)"

This reverts commit faa7a97fa929941cade5d62d2d680c6c3f34cdc8.

GitOrigin-RevId: 31c88ee836fb5e1ab3950da590c28e24b1397edb
Domagoj Kriskovic 7 месяцев назад
Родитель
Сommit
0a84cefc96

+ 0 - 5
services/document-updater/app/js/HistoryOTUpdateManager.js

@@ -118,11 +118,6 @@ async function tryApplyUpdate(projectId, docId, update, profiler) {
       // Just record the error here and acknowledge the write-op.
       Metrics.inc('history-queue-error')
     }
-    await RedisManager.promises.recordProjectNotificationTimestamp(
-      projectId,
-      update.meta.ts
-    )
-    profiler.log('recordProjectNotificationTimestamp')
   }
   RealTimeRedisManager.sendData({
     project_id: projectId,

+ 0 - 12
services/document-updater/app/js/RedisManager.js

@@ -567,18 +567,6 @@ const RedisManager = {
     }
   },
 
-  /*
-   * Record the timestamp of the update operation (if it doesn't already exist).
-   * This is used for email notifications
-   */
-  async recordProjectNotificationTimestamp(projectId, timestamp) {
-    await rclient.set(
-      keys.projectNotificationTimestamp({ project_id: projectId }),
-      timestamp,
-      'NX'
-    )
-  },
-
   async blockProject(projectId) {
     // Make sure that this MULTI operation only operates on project
     // specific keys, i.e. keys that have the project id in curly braces.

+ 0 - 6
services/document-updater/app/js/UpdateManager.js

@@ -195,12 +195,6 @@ const UpdateManager = {
           // Just record the error here and acknowledge the write-op.
           Metrics.inc('history-queue-error')
         }
-        const timestamp = update.meta?.ts || Date.now()
-        await RedisManager.promises.recordProjectNotificationTimestamp(
-          projectId,
-          timestamp
-        )
-        profile.log('recordProjectNotificationTimestamp')
       }
 
       if (rangesWereCollapsed) {

+ 0 - 38
services/document-updater/test/acceptance/js/ApplyingUpdatesToADocTests.js

@@ -113,15 +113,6 @@ describe('Applying updates to a doc', function () {
       body.should.deep.equal({})
     })
 
-    it('should set the project notification timestamp in Redis', async function () {
-      const timestamp = await rclientDU.get(
-        Keys.projectNotificationTimestamp({ project_id: this.project_id })
-      )
-      expect(timestamp).to.exist
-      const timestampValue = parseInt(timestamp, 10)
-      timestampValue.should.be.within(this.startTime, Date.now())
-    })
-
     describe('when sending another update', function () {
       beforeEach(async function () {
         this.timeout(10000)
@@ -167,16 +158,6 @@ describe('Applying updates to a doc', function () {
           await DocUpdaterClient.getProjectLastUpdatedAt(this.project_id)
         lastUpdatedAt.should.be.within(this.secondStartTime, Date.now())
       })
-
-      it('should not change the project notification timestamp', async function () {
-        const timestamp = await rclientDU.get(
-          Keys.projectNotificationTimestamp({ project_id: this.project_id })
-        )
-        expect(timestamp).to.exist
-        const timestampValue = parseInt(timestamp, 10)
-        // Should still be within the first update time range, not the second
-        timestampValue.should.be.within(this.startTime, this.secondStartTime)
-      })
     })
 
     describe('when another client is sending a concurrent update', function () {
@@ -294,15 +275,6 @@ describe('Applying updates to a doc', function () {
       body.should.deep.equal({})
     })
 
-    it('should set the project notification timestamp in Redis', async function () {
-      const timestamp = await rclientDU.get(
-        Keys.projectNotificationTimestamp({ project_id: this.project_id })
-      )
-      expect(timestamp).to.exist
-      const timestampValue = parseInt(timestamp, 10)
-      timestampValue.should.be.within(this.startTime, Date.now())
-    })
-
     describe('when sending another update', function () {
       beforeEach(async function () {
         this.timeout(10000)
@@ -353,16 +325,6 @@ describe('Applying updates to a doc', function () {
           await DocUpdaterClient.getProjectLastUpdatedAt(this.project_id)
         lastUpdatedAt.should.be.within(this.secondStartTime, Date.now())
       })
-
-      it('should not change the project notification timestamp', async function () {
-        const timestamp = await rclientDU.get(
-          Keys.projectNotificationTimestamp({ project_id: this.project_id })
-        )
-        expect(timestamp).to.exist
-        const timestampValue = parseInt(timestamp, 10)
-        // Should still be within the first update time range, not the second
-        timestampValue.should.be.within(this.startTime, this.secondStartTime)
-      })
     })
 
     describe('when another client is sending a concurrent update', function () {

+ 0 - 50
services/document-updater/test/unit/js/UpdateManager/UpdateManagerTests.js

@@ -35,7 +35,6 @@ describe('UpdateManager', function () {
       promises: {
         setDocument: sinon.stub().resolves(),
         updateDocument: sinon.stub(),
-        recordProjectNotificationTimestamp: sinon.stub().resolves(),
       },
     }
 
@@ -417,55 +416,6 @@ describe('UpdateManager', function () {
           this.historyUpdates.length
         )
       })
-
-      it('should record the project notification timestamp', function () {
-        this.RedisManager.promises.recordProjectNotificationTimestamp.should.have.been.calledWith(
-          this.project_id,
-          sinon.match.number
-        )
-      })
-    })
-
-    describe('when update has a timestamp in meta', function () {
-      beforeEach(async function () {
-        this.timestamp = 1234567890
-        this.update = {
-          op: [{ p: 42, i: 'foo' }],
-          meta: { ...this.updateMeta, ts: this.timestamp },
-        }
-        await this.UpdateManager.promises.applyUpdate(
-          this.project_id,
-          this.doc_id,
-          this.update
-        )
-      })
-
-      it('should record the project notification timestamp with the provided timestamp', function () {
-        this.RedisManager.promises.recordProjectNotificationTimestamp.should.have.been.calledWith(
-          this.project_id,
-          this.timestamp
-        )
-      })
-    })
-
-    describe('when there are no history updates', function () {
-      beforeEach(async function () {
-        this.RangesManager.applyUpdate.returns({
-          newRanges: this.updated_ranges,
-          rangesWereCollapsed: false,
-          historyUpdates: [],
-        })
-        await this.UpdateManager.promises.applyUpdate(
-          this.project_id,
-          this.doc_id,
-          this.update
-        )
-      })
-
-      it('should not record the project notification timestamp', function () {
-        this.RedisManager.promises.recordProjectNotificationTimestamp.should.not
-          .have.been.called
-      })
     })
 
     describe('with UTF-16 surrogate pairs in the update', function () {