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"
|
DiffCodec = require "./DiffCodec"
|
||||||
logger = require "logger-sharelatex"
|
logger = require "logger-sharelatex"
|
||||||
Metrics = require "./Metrics"
|
Metrics = require "./Metrics"
|
||||||
|
TrackChangesManager = require "./TrackChangesManager"
|
||||||
|
|
||||||
module.exports = DocumentManager =
|
module.exports = DocumentManager =
|
||||||
getDoc: (project_id, doc_id, _callback = (error, lines, version) ->) ->
|
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"
|
logger.log project_id: project_id, doc_id: doc_id, version: version, "flushing doc"
|
||||||
PersistenceManager.setDoc project_id, doc_id, lines, version, (error) ->
|
PersistenceManager.setDoc project_id, doc_id, lines, version, (error) ->
|
||||||
return callback(error) if 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) ->) ->
|
flushAndDeleteDoc: (project_id, doc_id, _callback = (error) ->) ->
|
||||||
timer = new Metrics.Timer("docManager.flushAndDeleteDoc")
|
timer = new Metrics.Timer("docManager.flushAndDeleteDoc")
|
||||||
|
|
|
@ -8,6 +8,7 @@ describe "DocumentUpdater - flushAndDeleteDoc", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@DocumentManager = SandboxedModule.require modulePath, requires:
|
@DocumentManager = SandboxedModule.require modulePath, requires:
|
||||||
"./RedisManager": @RedisManager = {}
|
"./RedisManager": @RedisManager = {}
|
||||||
|
"./TrackChangesManager": @TrackChangesManager = {}
|
||||||
"./PersistenceManager": @PersistenceManager = {}
|
"./PersistenceManager": @PersistenceManager = {}
|
||||||
"logger-sharelatex": @logger = {log: sinon.stub()}
|
"logger-sharelatex": @logger = {log: sinon.stub()}
|
||||||
"./DocOpsManager" :{}
|
"./DocOpsManager" :{}
|
||||||
|
|
|
@ -8,6 +8,7 @@ describe "DocumentUpdater - flushDocIfLoaded", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@DocumentManager = SandboxedModule.require modulePath, requires:
|
@DocumentManager = SandboxedModule.require modulePath, requires:
|
||||||
"./RedisManager": @RedisManager = {}
|
"./RedisManager": @RedisManager = {}
|
||||||
|
"./TrackChangesManager": @TrackChangesManager = {}
|
||||||
"./PersistenceManager": @PersistenceManager = {}
|
"./PersistenceManager": @PersistenceManager = {}
|
||||||
"./DocOpsManager": @DocOpsManager = {}
|
"./DocOpsManager": @DocOpsManager = {}
|
||||||
"logger-sharelatex": @logger = {log: sinon.stub()}
|
"logger-sharelatex": @logger = {log: sinon.stub()}
|
||||||
|
@ -23,6 +24,7 @@ describe "DocumentUpdater - flushDocIfLoaded", ->
|
||||||
describe "when the doc is in Redis", ->
|
describe "when the doc is in Redis", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@RedisManager.getDoc = sinon.stub().callsArgWith(1, null, @lines, @version)
|
@RedisManager.getDoc = sinon.stub().callsArgWith(1, null, @lines, @version)
|
||||||
|
@TrackChangesManager.flushDocChanges = sinon.stub().callsArg(2)
|
||||||
@PersistenceManager.setDoc = sinon.stub().callsArgWith(4)
|
@PersistenceManager.setDoc = sinon.stub().callsArgWith(4)
|
||||||
@DocumentManager.flushDocIfLoaded @project_id, @doc_id, @callback
|
@DocumentManager.flushDocIfLoaded @project_id, @doc_id, @callback
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ describe "DocumentUpdater - getDocAndRecentOps", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@DocumentManager = SandboxedModule.require modulePath, requires:
|
@DocumentManager = SandboxedModule.require modulePath, requires:
|
||||||
"./RedisManager": @RedisManager = {}
|
"./RedisManager": @RedisManager = {}
|
||||||
|
"./TrackChangesManager": @TrackChangesManager = {}
|
||||||
"./PersistenceManager": @PersistenceManager = {}
|
"./PersistenceManager": @PersistenceManager = {}
|
||||||
"./DocOpsManager": @DocOpsManager = {}
|
"./DocOpsManager": @DocOpsManager = {}
|
||||||
"logger-sharelatex": @logger = {log: sinon.stub()}
|
"logger-sharelatex": @logger = {log: sinon.stub()}
|
||||||
|
|
|
@ -8,6 +8,7 @@ describe "DocumentUpdater - getDoc", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@DocumentManager = SandboxedModule.require modulePath, requires:
|
@DocumentManager = SandboxedModule.require modulePath, requires:
|
||||||
"./RedisManager": @RedisManager = {}
|
"./RedisManager": @RedisManager = {}
|
||||||
|
"./TrackChangesManager": @TrackChangesManager = {}
|
||||||
"./PersistenceManager": @PersistenceManager = {}
|
"./PersistenceManager": @PersistenceManager = {}
|
||||||
"./DocOpsManager": @DocOpsManager = {}
|
"./DocOpsManager": @DocOpsManager = {}
|
||||||
"logger-sharelatex": @logger = {log: sinon.stub()}
|
"logger-sharelatex": @logger = {log: sinon.stub()}
|
||||||
|
|
|
@ -8,6 +8,7 @@ describe "DocumentManager - setDoc", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@DocumentManager = SandboxedModule.require modulePath, requires:
|
@DocumentManager = SandboxedModule.require modulePath, requires:
|
||||||
"./RedisManager": @RedisManager = {}
|
"./RedisManager": @RedisManager = {}
|
||||||
|
"./TrackChangesManager": @TrackChangesManager = {}
|
||||||
"./PersistenceManager": @PersistenceManager = {}
|
"./PersistenceManager": @PersistenceManager = {}
|
||||||
"./DiffCodec": @DiffCodec = {}
|
"./DiffCodec": @DiffCodec = {}
|
||||||
"./DocOpsManager":{}
|
"./DocOpsManager":{}
|
||||||
|
|
Loading…
Reference in a new issue