Merge pull request #4 from sharelatex/flush-ops-from-redis

push ops to track changes when document is flushed
This commit is contained in:
Brian Gough 2015-11-30 10:46:21 +00:00
commit 529a061567
6 changed files with 10 additions and 1 deletions

View file

@ -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")

View file

@ -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" :{}

View file

@ -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

View file

@ -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()}

View file

@ -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()}

View file

@ -8,6 +8,7 @@ describe "DocumentManager - setDoc", ->
beforeEach ->
@DocumentManager = SandboxedModule.require modulePath, requires:
"./RedisManager": @RedisManager = {}
"./TrackChangesManager": @TrackChangesManager = {}
"./PersistenceManager": @PersistenceManager = {}
"./DiffCodec": @DiffCodec = {}
"./DocOpsManager":{}