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

Revert "Merge pull request #33 from sharelatex/bg-add-timestamp-marker-to-project-history-queue"

This reverts commit 8ec398b133aa75c45384dd7ceb630cd743f4a15c, reversing
changes made to e3a6c934cf53fd245d7d0df737463cc90f954885.
Brian Gough 8 лет назад
Родитель
Сommit
e471730efb

+ 2 - 12
services/document-updater/app/coffee/ProjectHistoryRedisManager.coffee

@@ -4,18 +4,8 @@ rclient = require("redis-sharelatex").createClient(Settings.redis.documentupdate
 logger = require('logger-sharelatex')
 
 module.exports = ProjectHistoryRedisManager =
-	queueOps: (project_id, ops..., callback = (error, projectUpdateCount) ->) ->
-		multi = rclient.multi()
-		# Push the ops onto the project history queue
-		multi.rpush projectHistoryKeys.projectHistoryOps({project_id}), ops...
-		# To record the age of the oldest op on the queue set a timestamp if not
-		# already present (SETNX).
-		multi.setnx projectHistoryKeys.projectHistoryFirstOpTimestamp({project_id}), Date.now()
-		multi.exec (error, result) ->
-			return callback(error) if error?
-			# return the number of entries pushed onto the project history queue
-			callback null, result[0]
-
+	queueOps: (project_id, ops..., callback) ->
+		rclient.rpush projectHistoryKeys.projectHistoryOps({project_id}), ops..., callback
 
 	queueRenameEntity: (project_id, projectHistoryId, entity_type, entity_id, user_id, projectUpdate, callback) ->
 		projectUpdate =

+ 0 - 1
services/document-updater/config/settings.defaults.coffee

@@ -74,7 +74,6 @@ module.exports =
 		project_history:
 			key_schema:
 				projectHistoryOps: ({project_id}) -> "ProjectHistory:Ops:#{project_id}"
-				projectHistoryFirstOpTimestamp: ({project_id}) -> "ProjectHistory:FirstOpTimestamp:#{project_id}"
 			# cluster: [{
 			# 	port: "7000"
 			# 	host: "localhost"

+ 1 - 22
services/document-updater/test/acceptance/coffee/ApplyingUpdatesToADocTests.coffee

@@ -33,7 +33,7 @@ describe "Applying updates to a doc", ->
 		before (done) ->
 			[@project_id, @doc_id] = [DocUpdaterClient.randomId(), DocUpdaterClient.randomId()]
 			sinon.spy MockWebApi, "getDocument"
-			@startTime = Date.now()
+
 			MockWebApi.insertDoc @project_id, @doc_id, {lines: @lines, version: @version}
 			DocUpdaterClient.sendUpdate @project_id, @doc_id, @update, (error) ->
 				throw error if error?
@@ -67,27 +67,6 @@ describe "Applying updates to a doc", ->
 				JSON.parse(updates[0]).op.should.deep.equal @update.op
 				done()
 
-		it "should set the first op timestamp", (done) ->
-			rclient_history.get ProjectHistoryKeys.projectHistoryFirstOpTimestamp({@project_id}), (error, result) =>
-				throw error if error?
-				result.should.be.within(@startTime, Date.now())
-				@firstOpTimestamp = result
-				done()
-
-		describe "when sending another update", ->
-			before (done) ->
-				@second_update = Object.create(@update)
-				@second_update.v = @version + 1
-				DocUpdaterClient.sendUpdate @project_id, @doc_id, @second_update, (error) ->
-					throw error if error?
-					setTimeout done, 200
-
-			it "should not change the first op timestamp", (done) ->
-				rclient_history.get ProjectHistoryKeys.projectHistoryFirstOpTimestamp({@project_id}), (error, result) =>
-					throw error if error?
-					result.should.equal @firstOpTimestamp
-					done()
-
 	describe "when the document is loaded", ->
 		before (done) ->
 			[@project_id, @doc_id] = [DocUpdaterClient.randomId(), DocUpdaterClient.randomId()]

+ 3 - 14
services/document-updater/test/unit/coffee/ProjectHistoryRedisManager/ProjectHistoryRedisManagerTests.coffee

@@ -20,7 +20,6 @@ describe "ProjectHistoryRedisManager", ->
 						project_history:
 							key_schema:
 								projectHistoryOps: ({project_id}) -> "ProjectHistory:Ops:#{project_id}"
-								projectHistoryFirstOpTimestamp: ({project_id}) -> "ProjectHistory:FirstOpTimestamp:#{project_id}"
 				}
 				"redis-sharelatex":
 					createClient: () => @rclient
@@ -33,26 +32,16 @@ describe "ProjectHistoryRedisManager", ->
 	describe "queueOps", ->
 		beforeEach ->
 			@ops = ["mock-op-1", "mock-op-2"]
-			@multi = exec: sinon.stub()
-			@multi.rpush = sinon.stub()
-			@multi.setnx = sinon.stub()
-			@rclient.multi = () => @multi
-			# @rclient = multi: () => @multi
+			@rclient.rpush = sinon.stub()
 			@ProjectHistoryRedisManager.queueOps @project_id, @ops..., @callback
 
 		it "should queue an update", ->
-			@multi.rpush
+			@rclient.rpush
 				.calledWithExactly(
 					"ProjectHistory:Ops:#{@project_id}"
 					@ops[0]
 					@ops[1]
-				).should.equal true
-
-		it "should set the queue timestamp if not present", ->
-			@multi.setnx
-				.calledWithExactly(
-					"ProjectHistory:FirstOpTimestamp:#{@project_id}"
-					Date.now()
+					@callback
 				).should.equal true
 
 	describe "queueRenameEntity", ->