From 3ced808411cfad2678875a7401bf68a323c483dc Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Fri, 5 May 2017 15:19:31 +0100 Subject: [PATCH] Use a single accept changes method. --- .../DocumentUpdaterHandler.coffee | 22 +++---------------- .../controllers/ReviewPanelController.coffee | 2 +- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee b/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee index 2f1de61852..2de1e3b780 100644 --- a/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee +++ b/services/web/app/coffee/Features/DocumentUpdater/DocumentUpdaterHandler.coffee @@ -137,29 +137,13 @@ module.exports = DocumentUpdaterHandler = logger.error project_id:project_id, doc_id:doc_id, url: url, "doc updater returned a non-success status code: #{res.statusCode}" callback new Error("doc updater returned a non-success status code: #{res.statusCode}") - acceptChange: (project_id, doc_id, change_id, callback = (error) ->) -> - timer = new metrics.Timer("accept-change") - url = "#{settings.apis.documentupdater.url}/project/#{project_id}/doc/#{doc_id}/change/#{change_id}/accept" - logger.log {project_id, doc_id, change_id}, "accepting change in document updater" - request.post url, (error, res, body)-> - timer.done() - if error? - logger.error {err:error, project_id, doc_id, change_id}, "error accepting change in doc updater" - return callback(error) - if res.statusCode >= 200 and res.statusCode < 300 - logger.log {project_id, doc_id, change_id}, "accepted change in document updater" - return callback(null) - else - logger.error {project_id, doc_id, change_id}, "doc updater returned a non-success status code: #{res.statusCode}" - callback new Error("doc updater returned a non-success status code: #{res.statusCode}") - - bulkAcceptChanges: (project_id, doc_id, change_ids, callback = (error) ->) -> - timer = new metrics.Timer("bulk-accept-changes") + acceptChanges: (project_id, doc_id, change_ids = [], callback = (error) ->) -> + timer = new metrics.Timer("accept-changes") reqSettings = url: "#{settings.apis.documentupdater.url}/project/#{project_id}/doc/#{doc_id}/change/accept" json: change_ids: change_ids - logger.log {project_id, doc_id }, "bulk accepting #{ change_ids.length } changes" + logger.log {project_id, doc_id }, "accepting #{ change_ids.length } changes" request.post reqSettings, (error, res, body)-> timer.done() if error? diff --git a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee index bf5841c11b..107eec2086 100644 --- a/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee +++ b/services/web/public/coffee/ide/review-panel/controllers/ReviewPanelController.coffee @@ -78,7 +78,7 @@ define [ updateEntries(doc_id) $scope.$apply () -> - ide.socket.on "bulk-accept-changes", (doc_id, change_ids) -> + ide.socket.on "accept-changes", (doc_id, change_ids) -> if doc_id != $scope.editor.open_doc_id for change_id in change_ids getChangeTracker(doc_id).removeChangeId(change_id)