Browse Source

rename pushUncompressedHistoryOps

Brian Gough 9 years ago
parent
commit
2d158b03d7

+ 2 - 2
services/document-updater/app/coffee/HistoryManager.coffee

@@ -25,7 +25,7 @@ module.exports = HistoryManager =
 	pushUncompressedHistoryOps: (project_id, doc_id, ops = [], callback = (error) ->) ->
 		if ops.length == 0
 			return callback()
-		HistoryRedisManager.pushUncompressedHistoryOps project_id, doc_id, ops, (error, length) ->
+		HistoryRedisManager.recordDocHasHistoryOps project_id, doc_id, ops, (error, length) ->
 			return callback(error) if error?
 			# We want to flush every 50 ops, i.e. 50, 100, 150, etc
 			# Find out which 'block' (i.e. 0-49, 50-99) we were in before and after pushing these
@@ -41,4 +41,4 @@ module.exports = HistoryManager =
 				HistoryManager.flushDocChanges project_id, doc_id,  (error) ->
 					if error?
 						logger.error err: error, doc_id: doc_id, project_id: project_id, "error flushing doc to track changes api"
-			callback()
+			callback()

+ 1 - 1
services/document-updater/app/coffee/HistoryRedisManager.coffee

@@ -5,7 +5,7 @@ async = require "async"
 logger = require('logger-sharelatex')
 
 module.exports = HistoryRedisManager =
-	pushUncompressedHistoryOps: (project_id, doc_id, ops = [], callback = (error, length) ->) ->
+	recordDocHasHistoryOps: (project_id, doc_id, ops = [], callback = (error, length) ->) ->
 		if ops.length == 0
 			return callback(new Error("cannot push no ops")) # This should never be called with no ops, but protect against a redis error if we sent an empty array to rpush
 		logger.log project_id: project_id, doc_id: doc_id, "marking doc in project for history ops"

+ 8 - 8
services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee

@@ -47,11 +47,11 @@ describe "HistoryManager", ->
 
 		describe "pushing the op", ->
 			beforeEach ->
-				@HistoryRedisManager.pushUncompressedHistoryOps = sinon.stub().callsArgWith(3, null, 1)
+				@HistoryRedisManager.recordDocHasHistoryOps = sinon.stub().callsArgWith(3, null, 1)
 				@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback
 
 			it "should push the ops into redis", ->
-				@HistoryRedisManager.pushUncompressedHistoryOps
+				@HistoryRedisManager.recordDocHasHistoryOps
 					.calledWith(@project_id, @doc_id, @ops)
 					.should.equal true
 
@@ -63,7 +63,7 @@ describe "HistoryManager", ->
 
 		describe "when we hit a multiple of FLUSH_EVERY_N_OPS ops", ->
 			beforeEach ->
-				@HistoryRedisManager.pushUncompressedHistoryOps =
+				@HistoryRedisManager.recordDocHasHistoryOps =
 					sinon.stub().callsArgWith(3, null, 2 * @HistoryManager.FLUSH_EVERY_N_OPS)
 				@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback
 
@@ -75,7 +75,7 @@ describe "HistoryManager", ->
 		describe "when we go over a multiple of FLUSH_EVERY_N_OPS ops", ->
 			beforeEach ->
 				@ops = ["op1", "op2", "op3"]
-				@HistoryRedisManager.pushUncompressedHistoryOps =
+				@HistoryRedisManager.recordDocHasHistoryOps =
 					sinon.stub().callsArgWith(3, null, 2 * @HistoryManager.FLUSH_EVERY_N_OPS + 1)
 				@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback
 
@@ -86,7 +86,7 @@ describe "HistoryManager", ->
 
 		describe "when HistoryManager errors", ->
 			beforeEach ->
-				@HistoryRedisManager.pushUncompressedHistoryOps =
+				@HistoryRedisManager.recordDocHasHistoryOps =
 					sinon.stub().callsArgWith(3, null, 2 * @HistoryManager.FLUSH_EVERY_N_OPS)
 				@HistoryManager.flushDocChanges = sinon.stub().callsArgWith(2, @error = new Error("oops"))
 				@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback
@@ -103,10 +103,10 @@ describe "HistoryManager", ->
 		
 		describe "with no ops", ->
 			beforeEach ->
-				@HistoryRedisManager.pushUncompressedHistoryOps = sinon.stub().callsArgWith(3, null, 1)
+				@HistoryRedisManager.recordDocHasHistoryOps = sinon.stub().callsArgWith(3, null, 1)
 				@HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, [], @callback
 			
-			it "should not call HistoryRedisManager.pushUncompressedHistoryOps", ->
-				@HistoryRedisManager.pushUncompressedHistoryOps.called.should.equal false
+			it "should not call HistoryRedisManager.recordDocHasHistoryOps", ->
+				@HistoryRedisManager.recordDocHasHistoryOps.called.should.equal false
 			
 

+ 3 - 3
services/document-updater/test/unit/coffee/HistoryRedisManager/HistoryRedisManagerTests.coffee

@@ -24,7 +24,7 @@ describe "HistoryRedisManager", ->
 		@project_id = "project-id-123"
 		@callback = sinon.stub()
 
-	describe "pushUncompressedHistoryOps", ->
+	describe "recordDocHasHistoryOps", ->
 		beforeEach ->
 			@ops = [{ op: [{ i: "foo", p: 4 }] },{ op: [{ i: "bar", p: 56 }] }]
 			@rclient.llen = sinon.stub().yields(null, @length = 42)
@@ -32,7 +32,7 @@ describe "HistoryRedisManager", ->
 		
 		describe "with ops", ->
 			beforeEach (done) ->
-				@HistoryRedisManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, (args...) =>
+				@HistoryRedisManager.recordDocHasHistoryOps @project_id, @doc_id, @ops, (args...) =>
 					@callback(args...)
 					done()
 			
@@ -46,7 +46,7 @@ describe "HistoryRedisManager", ->
 		
 		describe "with no ops", ->
 			beforeEach (done) ->
-				@HistoryRedisManager.pushUncompressedHistoryOps @project_id, @doc_id, [], (args...) =>
+				@HistoryRedisManager.recordDocHasHistoryOps @project_id, @doc_id, [], (args...) =>
 					@callback(args...)
 					done()