mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Return track changes entries in HTTP request
This commit is contained in:
parent
4fadd75ef3
commit
418405e8b9
5 changed files with 13 additions and 11 deletions
|
@ -26,20 +26,20 @@ module.exports = DocumentManager =
|
|||
else
|
||||
callback null, lines, version, track_changes_entries, true
|
||||
|
||||
getDocAndRecentOps: (project_id, doc_id, fromVersion, _callback = (error, lines, version, recentOps) ->) ->
|
||||
getDocAndRecentOps: (project_id, doc_id, fromVersion, _callback = (error, lines, version, recentOps, track_changes_entries) ->) ->
|
||||
timer = new Metrics.Timer("docManager.getDocAndRecentOps")
|
||||
callback = (args...) ->
|
||||
timer.done()
|
||||
_callback(args...)
|
||||
|
||||
DocumentManager.getDoc project_id, doc_id, (error, lines, version) ->
|
||||
DocumentManager.getDoc project_id, doc_id, (error, lines, version, track_changes_entries) ->
|
||||
return callback(error) if error?
|
||||
if fromVersion == -1
|
||||
callback null, lines, version, []
|
||||
callback null, lines, version, [], track_changes_entries
|
||||
else
|
||||
RedisManager.getPreviousDocOps doc_id, fromVersion, version, (error, ops) ->
|
||||
return callback(error) if error?
|
||||
callback null, lines, version, ops
|
||||
callback null, lines, version, ops, track_changes_entries
|
||||
|
||||
setDoc: (project_id, doc_id, newLines, source, user_id, _callback = (error) ->) ->
|
||||
timer = new Metrics.Timer("docManager.setDoc")
|
||||
|
|
|
@ -18,7 +18,7 @@ module.exports = HttpController =
|
|||
else
|
||||
fromVersion = -1
|
||||
|
||||
DocumentManager.getDocAndRecentOpsWithLock project_id, doc_id, fromVersion, (error, lines, version, ops) ->
|
||||
DocumentManager.getDocAndRecentOpsWithLock project_id, doc_id, fromVersion, (error, lines, version, ops, track_changes_entries) ->
|
||||
timer.done()
|
||||
return next(error) if error?
|
||||
logger.log project_id: project_id, doc_id: doc_id, "got doc via http"
|
||||
|
@ -29,6 +29,7 @@ module.exports = HttpController =
|
|||
lines: lines
|
||||
version: version
|
||||
ops: ops
|
||||
track_changes_entries: track_changes_entries
|
||||
|
||||
_getTotalSizeOfLines: (lines) ->
|
||||
size = 0
|
||||
|
|
|
@ -47,10 +47,9 @@ describe "Track changes", ->
|
|||
setTimeout done, 200
|
||||
|
||||
it "should set the updated track changes entries in redis", (done) ->
|
||||
console.log "TODO: GET ME FROM HTTP REQUEST"
|
||||
rclient.get "TrackChangesEntries:#{@doc.id}", (error, value) =>
|
||||
DocUpdaterClient.getDoc @project_id, @doc.id, (error, res, data) =>
|
||||
throw error if error?
|
||||
entries = JSON.parse(value)
|
||||
entries = data.track_changes_entries
|
||||
change = entries.changes[0]
|
||||
change.op.should.deep.equal { i: "456", p: 3 }
|
||||
change.metadata.user_id.should.equal @user_id
|
||||
|
|
|
@ -117,7 +117,7 @@ describe "DocumentManager", ->
|
|||
.should.equal true
|
||||
|
||||
it "should call the callback with the doc info", ->
|
||||
@callback.calledWith(null, @lines, @version, @ops).should.equal true
|
||||
@callback.calledWith(null, @lines, @version, @ops, @track_changes_entries).should.equal true
|
||||
|
||||
it "should time the execution", ->
|
||||
@Metrics.Timer::done.called.should.equal true
|
||||
|
@ -137,7 +137,7 @@ describe "DocumentManager", ->
|
|||
@RedisManager.getPreviousDocOps.called.should.equal false
|
||||
|
||||
it "should call the callback with the doc info", ->
|
||||
@callback.calledWith(null, @lines, @version, []).should.equal true
|
||||
@callback.calledWith(null, @lines, @version, [], @track_changes_entries).should.equal true
|
||||
|
||||
it "should time the execution", ->
|
||||
@Metrics.Timer::done.called.should.equal true
|
||||
|
|
|
@ -22,6 +22,7 @@ describe "HttpController.getDoc", ->
|
|||
@ops = ["mock-op-1", "mock-op-2"]
|
||||
@version = 42
|
||||
@fromVersion = 42
|
||||
@track_changes_entries = { changes: "mock", comments: "mock" }
|
||||
@res =
|
||||
send: sinon.stub()
|
||||
@req =
|
||||
|
@ -32,7 +33,7 @@ describe "HttpController.getDoc", ->
|
|||
|
||||
describe "when the document exists and no recent ops are requested", ->
|
||||
beforeEach ->
|
||||
@DocumentManager.getDocAndRecentOpsWithLock = sinon.stub().callsArgWith(3, null, @lines, @version, [])
|
||||
@DocumentManager.getDocAndRecentOpsWithLock = sinon.stub().callsArgWith(3, null, @lines, @version, [], @track_changes_entries)
|
||||
@HttpController.getDoc(@req, @res, @next)
|
||||
|
||||
it "should get the doc", ->
|
||||
|
@ -47,6 +48,7 @@ describe "HttpController.getDoc", ->
|
|||
lines: @lines
|
||||
version: @version
|
||||
ops: []
|
||||
track_changes_entries: @track_changes_entries
|
||||
}))
|
||||
.should.equal true
|
||||
|
||||
|
|
Loading…
Reference in a new issue