mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-01 04:53:03 +00:00
Merge pull request #54 from overleaf/bg-use-background-flush-on-disconnect
use background flush on disconnect
This commit is contained in:
commit
9da98614c7
2 changed files with 4 additions and 2 deletions
|
@ -36,9 +36,11 @@ module.exports = DocumentUpdaterManager =
|
||||||
callback err
|
callback err
|
||||||
|
|
||||||
flushProjectToMongoAndDelete: (project_id, callback = ()->) ->
|
flushProjectToMongoAndDelete: (project_id, callback = ()->) ->
|
||||||
|
# this method is called when the last connected user leaves the project
|
||||||
logger.log project_id:project_id, "deleting project from document updater"
|
logger.log project_id:project_id, "deleting project from document updater"
|
||||||
timer = new metrics.Timer("delete.mongo.project")
|
timer = new metrics.Timer("delete.mongo.project")
|
||||||
url = "#{settings.apis.documentupdater.url}/project/#{project_id}"
|
# flush the project in the background when all users have left
|
||||||
|
url = "#{settings.apis.documentupdater.url}/project/#{project_id}?background=true"
|
||||||
request.del url, (err, res, body)->
|
request.del url, (err, res, body)->
|
||||||
timer.done()
|
timer.done()
|
||||||
if err?
|
if err?
|
||||||
|
|
|
@ -93,7 +93,7 @@ describe 'DocumentUpdaterManager', ->
|
||||||
@DocumentUpdaterManager.flushProjectToMongoAndDelete @project_id, @callback
|
@DocumentUpdaterManager.flushProjectToMongoAndDelete @project_id, @callback
|
||||||
|
|
||||||
it 'should delete the project from the document updater', ->
|
it 'should delete the project from the document updater', ->
|
||||||
url = "#{@settings.apis.documentupdater.url}/project/#{@project_id}"
|
url = "#{@settings.apis.documentupdater.url}/project/#{@project_id}?background=true"
|
||||||
@request.del.calledWith(url).should.equal true
|
@request.del.calledWith(url).should.equal true
|
||||||
|
|
||||||
it "should call the callback with no error", ->
|
it "should call the callback with no error", ->
|
||||||
|
|
Loading…
Reference in a new issue