From cd60817592c8ed4535288c47dec17cbe80b48103 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Wed, 16 Jul 2014 11:37:17 +0100 Subject: [PATCH] made getting templates details parallel --- .../Features/Templates/TemplatesController.coffee | 14 ++++++++++---- .../Templates/TemplatesPublisherTests.coffee | 5 ++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/services/web/app/coffee/Features/Templates/TemplatesController.coffee b/services/web/app/coffee/Features/Templates/TemplatesController.coffee index 11a78cdb12..4f8268da10 100644 --- a/services/web/app/coffee/Features/Templates/TemplatesController.coffee +++ b/services/web/app/coffee/Features/Templates/TemplatesController.coffee @@ -8,6 +8,7 @@ fs = require('fs') request = require('request') uuid = require('node-uuid') logger = require('logger-sharelatex') +async = require("async") module.exports = @@ -44,13 +45,18 @@ module.exports = TemplatesPublisher.unpublish user_id, project_id, callback getTemplateDetails: (user_id, project_id, callback)-> - TemplatesPublisher.getTemplateDetails user_id, project_id, (err, details)-> + async.parallel { + details: (cb)-> + TemplatesPublisher.getTemplateDetails user_id, project_id, cb + description: (cb)-> + ProjectDetailsHandler.getProjectDescription project_id, cb + }, (err, results)-> if err? logger.err err:err, user_id:user_id, project_id:project_id, "something went wrong getting template details" return callback(err) - ProjectDetailsHandler.getProjectDescription project_id, (err, description)-> - details.description = description - callback(err, details) + details = results.details + details.description = results.description + callback(err, details) setCompiler = (project_id, compiler, callback)-> diff --git a/services/web/test/UnitTests/coffee/Templates/TemplatesPublisherTests.coffee b/services/web/test/UnitTests/coffee/Templates/TemplatesPublisherTests.coffee index 9142a88840..2443b87e7e 100644 --- a/services/web/test/UnitTests/coffee/Templates/TemplatesPublisherTests.coffee +++ b/services/web/test/UnitTests/coffee/Templates/TemplatesPublisherTests.coffee @@ -20,7 +20,10 @@ describe 'Templates publish', -> @TemplatesPublisher = SandboxedModule.require modulePath, requires: "request": @request "settings-sharelatex":@settings - + "logger-sharelatex": + log:-> + err:-> + @project_id = "12312132" @user_id = "132jlkjdsaoij"