From d228fd88ab53978d6889eb74566cf8de757d435d Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 11 Sep 2015 09:53:06 -0300 Subject: [PATCH] add worcount file param --- .../Features/Compile/ClsiManager.coffee | 27 ++++++++++--------- .../Features/Compile/CompileController.coffee | 3 ++- .../Features/Compile/CompileManager.coffee | 4 +-- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/services/web/app/coffee/Features/Compile/ClsiManager.coffee b/services/web/app/coffee/Features/Compile/ClsiManager.coffee index 0ee43d75dd..f5c79f12df 100755 --- a/services/web/app/coffee/Features/Compile/ClsiManager.coffee +++ b/services/web/app/coffee/Features/Compile/ClsiManager.coffee @@ -106,15 +106,18 @@ module.exports = ClsiManager = resources: resources } - wordCount: (project_id, options, callback = (error, response) ->) -> - compilerUrl = @_getCompilerUrl(options?.compileGroup) - request.get { - url: "#{compilerUrl}/project/#{project_id}/wordcount" - }, (error, response, body) -> - return callback(error) if error? - if 200 <= response.statusCode < 300 - callback null, body - else - error = new Error("CLSI returned non-success code: #{response.statusCode}") - logger.error err: error, project_id: project_id, "CLSI returned failure code" - callback error, body + wordCount: (project_id, file, options, callback = (error, response) ->) -> + ClsiManager._buildRequest project_id, options, (error, req) -> + compilerUrl = ClsiManager._getCompilerUrl(options?.compileGroup) + filename = file || req.compile.rootResourcePath + request.get { + url: "#{compilerUrl}/project/#{project_id}/wordcount?file=#{filename}" + }, (error, response, body) -> + return callback(error) if error? + if 200 <= response.statusCode < 300 + callback null, body + else + error = new Error("CLSI returned non-success code: #{response.statusCode}") + logger.error err: error, project_id: project_id, "CLSI returned failure code" + callback error, body + diff --git a/services/web/app/coffee/Features/Compile/CompileController.coffee b/services/web/app/coffee/Features/Compile/CompileController.coffee index 972bc5b948..d00a4375c7 100755 --- a/services/web/app/coffee/Features/Compile/CompileController.coffee +++ b/services/web/app/coffee/Features/Compile/CompileController.coffee @@ -105,7 +105,8 @@ module.exports = CompileController = wordCount: (req, res, next) -> project_id = req.params.Project_id - CompileManager.wordCount project_id, (error, body) -> + file = req.query.file || false + CompileManager.wordCount project_id, file, (error, body) -> return next(error) if error? res.contentType("application/json") res.send 200, body diff --git a/services/web/app/coffee/Features/Compile/CompileManager.coffee b/services/web/app/coffee/Features/Compile/CompileManager.coffee index 04810937a0..7cac827789 100755 --- a/services/web/app/coffee/Features/Compile/CompileManager.coffee +++ b/services/web/app/coffee/Features/Compile/CompileManager.coffee @@ -91,7 +91,7 @@ module.exports = CompileManager = else ProjectRootDocManager.setRootDocAutomatically project_id, callback - wordCount: (project_id, callback = (error) ->) -> + wordCount: (project_id, file, callback = (error) ->) -> CompileManager.getProjectCompileLimits project_id, (error, limits) -> return callback(error) if error? - ClsiManager.wordCount project_id, limits, callback + ClsiManager.wordCount project_id, file, limits, callback