mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #4 from sharelatex/flush-ops-from-redis
push ops to track changes when document is flushed
This commit is contained in:
commit
529a061567
6 changed files with 10 additions and 1 deletions
|
@ -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")
|
||||
|
|
|
@ -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" :{}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()}
|
||||
|
|
|
@ -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()}
|
||||
|
|
|
@ -8,6 +8,7 @@ describe "DocumentManager - setDoc", ->
|
|||
beforeEach ->
|
||||
@DocumentManager = SandboxedModule.require modulePath, requires:
|
||||
"./RedisManager": @RedisManager = {}
|
||||
"./TrackChangesManager": @TrackChangesManager = {}
|
||||
"./PersistenceManager": @PersistenceManager = {}
|
||||
"./DiffCodec": @DiffCodec = {}
|
||||
"./DocOpsManager":{}
|
||||
|
|
Loading…
Reference in a new issue