From 60db8bf5dec1cf25c80bd3ece340281127318021 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 27 May 2015 16:21:50 +0100 Subject: [PATCH] flush ops when document is flushed --- services/document-updater/app/coffee/DocumentManager.coffee | 5 ++++- .../coffee/DocumentManager/flushAndDeleteDocTests.coffee | 1 + .../test/unit/coffee/DocumentManager/flushDocTests.coffee | 2 ++ .../coffee/DocumentManager/getDocAndRecentOpsTests.coffee | 1 + .../test/unit/coffee/DocumentManager/getDocTests.coffee | 1 + .../test/unit/coffee/DocumentManager/setDocTests.coffee | 1 + 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/services/document-updater/app/coffee/DocumentManager.coffee b/services/document-updater/app/coffee/DocumentManager.coffee index 0faa8d2b8a..81fa0aa66c 100644 --- a/services/document-updater/app/coffee/DocumentManager.coffee +++ b/services/document-updater/app/coffee/DocumentManager.coffee @@ -4,6 +4,7 @@ DocOpsManager = require "./DocOpsManager" DiffCodec = require "./DiffCodec" logger = require "logger-sharelatex" Metrics = require "./Metrics" +TrackChangesManager = require "./TrackChangesManager" module.exports = DocumentManager = getDoc: (project_id, doc_id, _callback = (error, lines, version) ->) -> @@ -90,7 +91,9 @@ module.exports = DocumentManager = logger.log project_id: project_id, doc_id: doc_id, version: version, "flushing doc" PersistenceManager.setDoc project_id, doc_id, lines, version, (error) -> return callback(error) if error? - callback null + TrackChangesManager.flushDocChanges project_id, doc_id, (error) -> + return callback(error) if error? + callback null flushAndDeleteDoc: (project_id, doc_id, _callback = (error) ->) -> timer = new Metrics.Timer("docManager.flushAndDeleteDoc") diff --git a/services/document-updater/test/unit/coffee/DocumentManager/flushAndDeleteDocTests.coffee b/services/document-updater/test/unit/coffee/DocumentManager/flushAndDeleteDocTests.coffee index 85a25ee5a7..c4a6ef3d1a 100644 --- a/services/document-updater/test/unit/coffee/DocumentManager/flushAndDeleteDocTests.coffee +++ b/services/document-updater/test/unit/coffee/DocumentManager/flushAndDeleteDocTests.coffee @@ -8,6 +8,7 @@ describe "DocumentUpdater - flushAndDeleteDoc", -> beforeEach -> @DocumentManager = SandboxedModule.require modulePath, requires: "./RedisManager": @RedisManager = {} + "./TrackChangesManager": @TrackChangesManager = {} "./PersistenceManager": @PersistenceManager = {} "logger-sharelatex": @logger = {log: sinon.stub()} "./DocOpsManager" :{} diff --git a/services/document-updater/test/unit/coffee/DocumentManager/flushDocTests.coffee b/services/document-updater/test/unit/coffee/DocumentManager/flushDocTests.coffee index 6bdba1a2b7..551b444f7f 100644 --- a/services/document-updater/test/unit/coffee/DocumentManager/flushDocTests.coffee +++ b/services/document-updater/test/unit/coffee/DocumentManager/flushDocTests.coffee @@ -8,6 +8,7 @@ describe "DocumentUpdater - flushDocIfLoaded", -> beforeEach -> @DocumentManager = SandboxedModule.require modulePath, requires: "./RedisManager": @RedisManager = {} + "./TrackChangesManager": @TrackChangesManager = {} "./PersistenceManager": @PersistenceManager = {} "./DocOpsManager": @DocOpsManager = {} "logger-sharelatex": @logger = {log: sinon.stub()} @@ -23,6 +24,7 @@ describe "DocumentUpdater - flushDocIfLoaded", -> describe "when the doc is in Redis", -> beforeEach -> @RedisManager.getDoc = sinon.stub().callsArgWith(1, null, @lines, @version) + @TrackChangesManager.flushDocChanges = sinon.stub().callsArg(2) @PersistenceManager.setDoc = sinon.stub().callsArgWith(4) @DocumentManager.flushDocIfLoaded @project_id, @doc_id, @callback diff --git a/services/document-updater/test/unit/coffee/DocumentManager/getDocAndRecentOpsTests.coffee b/services/document-updater/test/unit/coffee/DocumentManager/getDocAndRecentOpsTests.coffee index 7a296cc47d..1e5f521b36 100644 --- a/services/document-updater/test/unit/coffee/DocumentManager/getDocAndRecentOpsTests.coffee +++ b/services/document-updater/test/unit/coffee/DocumentManager/getDocAndRecentOpsTests.coffee @@ -8,6 +8,7 @@ describe "DocumentUpdater - getDocAndRecentOps", -> beforeEach -> @DocumentManager = SandboxedModule.require modulePath, requires: "./RedisManager": @RedisManager = {} + "./TrackChangesManager": @TrackChangesManager = {} "./PersistenceManager": @PersistenceManager = {} "./DocOpsManager": @DocOpsManager = {} "logger-sharelatex": @logger = {log: sinon.stub()} diff --git a/services/document-updater/test/unit/coffee/DocumentManager/getDocTests.coffee b/services/document-updater/test/unit/coffee/DocumentManager/getDocTests.coffee index ea68890199..9d95d46a87 100644 --- a/services/document-updater/test/unit/coffee/DocumentManager/getDocTests.coffee +++ b/services/document-updater/test/unit/coffee/DocumentManager/getDocTests.coffee @@ -8,6 +8,7 @@ describe "DocumentUpdater - getDoc", -> beforeEach -> @DocumentManager = SandboxedModule.require modulePath, requires: "./RedisManager": @RedisManager = {} + "./TrackChangesManager": @TrackChangesManager = {} "./PersistenceManager": @PersistenceManager = {} "./DocOpsManager": @DocOpsManager = {} "logger-sharelatex": @logger = {log: sinon.stub()} diff --git a/services/document-updater/test/unit/coffee/DocumentManager/setDocTests.coffee b/services/document-updater/test/unit/coffee/DocumentManager/setDocTests.coffee index b827b584f8..a1667a6669 100644 --- a/services/document-updater/test/unit/coffee/DocumentManager/setDocTests.coffee +++ b/services/document-updater/test/unit/coffee/DocumentManager/setDocTests.coffee @@ -8,6 +8,7 @@ describe "DocumentManager - setDoc", -> beforeEach -> @DocumentManager = SandboxedModule.require modulePath, requires: "./RedisManager": @RedisManager = {} + "./TrackChangesManager": @TrackChangesManager = {} "./PersistenceManager": @PersistenceManager = {} "./DiffCodec": @DiffCodec = {} "./DocOpsManager":{}