From 21526ac7f3d6b56231c90bd9b64a24361585f552 Mon Sep 17 00:00:00 2001 From: Ghost141 Date: Fri, 17 Oct 2014 02:37:51 +0800 Subject: [PATCH] Update search challenges api and fix some jslint error. --- actions/challengeRegistration.js | 2 +- actions/docusign.js | 5 ++- actions/reports.js | 6 ++-- actions/srmProblems.js | 4 +-- actions/srmRoundComponentsAndTerms.js | 4 +-- actions/srmRoundManagement.js | 26 +++++++-------- initializers/configurator.js | 40 +++++++++++------------ queries/challenge_details | 2 +- queries/search_software_studio_challenges | 2 +- routes.js | 4 +-- 10 files changed, 47 insertions(+), 48 deletions(-) diff --git a/actions/challengeRegistration.js b/actions/challengeRegistration.js index e465a5748..95036f871 100644 --- a/actions/challengeRegistration.js +++ b/actions/challengeRegistration.js @@ -306,7 +306,7 @@ var projectTrack = function (api, userId, challengeId, componentInfo, dbConnecti function (cb) { //Rating var rating = componentInfo.rating; - + if (rating > 0) { persistResourceInfo(api, resourceId, 4, componentInfo.rating, userId, dbConnectionMap, cb); } else { diff --git a/actions/docusign.js b/actions/docusign.js index befd6b862..572e8f95a 100644 --- a/actions/docusign.js +++ b/actions/docusign.js @@ -415,7 +415,7 @@ exports.generateDocusignViewURL = { }); } - textTabs.push({tabLabel :'TopCoder Handle', value: user.handle}); + textTabs.push({tabLabel : 'TopCoder Handle', value: user.handle}); //Prepare the POST parameters reqParams = { @@ -477,8 +477,7 @@ exports.generateDocusignViewURL = { var url, returnURL, reqParams; //Create the return url - returnURL = _.template(connection.params.returnUrl ? - connection.params.returnUrl : api.config.tcConfig.docusign.returnURL)({envelopeId: envelopeId}); + returnURL = _.template(connection.params.returnUrl || api.config.tcConfig.docusign.returnURL)({envelopeId: envelopeId}); //Request recipient view url = baseURL + "/envelopes/" + envelopeId + "/views/recipient"; diff --git a/actions/reports.js b/actions/reports.js index 92c989f06..350e38517 100644 --- a/actions/reports.js +++ b/actions/reports.js @@ -538,7 +538,7 @@ var clientChallengeCosts = function (api, connection, next) { cb(new NotFoundError('Client not found')); return; } - if(type === helper.ListType.ACTIVE) { + if (type === helper.ListType.ACTIVE) { api.dataAccess.executeQuery("active_client_challenges_costs", sqlParameters, dbConnectionMap, cb); } else { api.dataAccess.executeQuery("past_client_challenges_costs", sqlParameters, dbConnectionMap, cb); @@ -649,8 +649,8 @@ exports.getClientActiveChallengeCosts = { api.dataAccess.executeQuery("get_client_active_challenge_costs", sqlParameters, dbConnectionMap, cb); }, function (results, cb) { costs = _.map(results, function (item) { - var duration = item.challenge_duration ? parseFloat(item.challenge_duration.toFixed(1)) : 0; - var currentPhaseText = item.current_phase; + var duration = item.challenge_duration ? parseFloat(item.challenge_duration.toFixed(1)) : 0, + currentPhaseText = item.current_phase; /* currentPhaseArray = []; if (currentPhaseText) { diff --git a/actions/srmProblems.js b/actions/srmProblems.js index 06e57906c..081be8d2c 100644 --- a/actions/srmProblems.js +++ b/actions/srmProblems.js @@ -31,7 +31,7 @@ var ForbiddenError = require('../errors/ForbiddenError'); */ function parseProblem(item) { var type = {id: item.problem_type_id, description: item.problem_type_desc}, - status = {id: item.status_id, description: item.status_desc}; + status = {id: item.status_id, description: item.status_desc}; return {id: item.problem_id, name: item.name, proposedDivisionId: item.division_id, type: type, status: status}; } @@ -65,7 +65,7 @@ var listRoundProblems = function (api, connection, dbConnectionMap, next) { _.each(results, function (item) { var division = {id: item.division_id, desc: item.division_desc}, problem = parseProblem(item); - problem.roundId = roundId; + problem.roundId = roundId; result.push({division: division, problemData: problem}); }); diff --git a/actions/srmRoundComponentsAndTerms.js b/actions/srmRoundComponentsAndTerms.js index c653f11db..b0808503a 100644 --- a/actions/srmRoundComponentsAndTerms.js +++ b/actions/srmRoundComponentsAndTerms.js @@ -99,7 +99,7 @@ function checkComponents(api, dbConnectionMap, components, callback) { }, function (results, cb) { if (!error) { if (results.length === 0) { - error = new IllegalArgumentError("The componentId "+ component.componentId + " does not exist in database."); + error = new IllegalArgumentError("The componentId " + component.componentId + " does not exist in database."); } } @@ -348,4 +348,4 @@ exports.setRoundTerms = { api.helper.handleNoConnection(api, connection, next); } } -}; \ No newline at end of file +}; diff --git a/actions/srmRoundManagement.js b/actions/srmRoundManagement.js index 64924dca3..c03d09198 100644 --- a/actions/srmRoundManagement.js +++ b/actions/srmRoundManagement.js @@ -430,18 +430,18 @@ exports.createSRMContestRound = { function (roundId, cbx) { params.id = roundId; api.dataAccess.executeQuery('insert_srm_contest_round', - { - contest_id: params.contest_id, - round_id: params.id, - round_type_id: params.type.id, - registration_limit: params.registrationLimit, - invitational: params.invitationalType, - region_id: params.region.region_id, - name: params.name, - status: params.status, - short_name: params.short_name - }, - dbConnectionMap, cbx); + { + contest_id: params.contest_id, + round_id: params.id, + round_type_id: params.type.id, + registration_limit: params.registrationLimit, + invitational: params.invitationalType, + region_id: params.region.region_id, + name: params.name, + status: params.status, + short_name: params.short_name + }, + dbConnectionMap, cbx); } ], cb); }, @@ -781,4 +781,4 @@ exports.deleteSRMContestRound = { next(connection, true); }); } -}; \ No newline at end of file +}; diff --git a/initializers/configurator.js b/initializers/configurator.js index c8d71a3c5..89903d0cd 100644 --- a/initializers/configurator.js +++ b/initializers/configurator.js @@ -6,25 +6,25 @@ */ "use strict"; -exports.configurator = function(api, next){ +exports.configurator = function (api, next) { - api.configurator = { - _start: function(api, next){ - this.configWeb(api); - next(); - }, - configWeb: function(api){ - if(!api.servers || !api.servers.servers['web'] || !api.servers.servers['web'].server) { - api.log('[configurator] web server has not been created.', 'warning'); - return; - } - - var timeout = api.config.servers.web.timeout || 10 * 60 * 1000; - - api.servers.servers['web'].server.timeout = timeout; - api.log('[configurator] web.server#timeout => '+timeout, 'info'); - } - }; + api.configurator = { + _start: function (api, next) { + this.configWeb(api); + next(); + }, + configWeb: function (api) { + if (!api.servers || !api.servers.servers.web || !api.servers.servers.web.server) { + api.log('[configurator] web server has not been created.', 'warning'); + return; + } - next(); -} \ No newline at end of file + var timeout = api.config.servers.web.timeout || 10 * 60 * 1000; + + api.servers.servers.web.server.timeout = timeout; + api.log('[configurator] web.server#timeout => ' + timeout, 'info'); + } + }; + + next(); +}; diff --git a/queries/challenge_details b/queries/challenge_details index 02bfa236a..953bc79d9 100755 --- a/queries/challenge_details +++ b/queries/challenge_details @@ -139,7 +139,7 @@ SELECT AND pi52.project_id = p.project_id AND pi78.project_info_type_id = 78 -- forum type AND pi78.project_id = p.project_id - AND p.project_Id = nd_phase.project_id + AND p.project_id = nd_phase.project_id AND nd_phase.phase_type_id = (SELECT MIN(phase_type_id) FROM project_phase WHERE project_id = p.project_id AND phase_status_id = 2 AND phase_type_id not in (13,14)) AND p.project_category_id = pcl.project_category_id AND pcl.project_type_id IN (@project_type_id@) diff --git a/queries/search_software_studio_challenges b/queries/search_software_studio_challenges index 0de29683a..48f850e67 100644 --- a/queries/search_software_studio_challenges +++ b/queries/search_software_studio_challenges @@ -95,7 +95,7 @@ FIRST @pageSize@ AND pi4.project_id = p.project_id AND pi4.project_info_type_id = 4 --forum id AND p.project_Id = nd_phase.project_id - AND nd_phase.project_phase_id = (SELECT MAX(project_phase_id) FROM project_phase WHERE project_id = p.project_id AND phase_status_id = 2 AND phase_type_id IN (1,2,3,4,5,6,7,8,9,10,11,12)) + AND nd_phase.phase_type_id = (SELECT MIN(phase_type_id) FROM project_phase WHERE project_id = p.project_id AND phase_status_id = 2 AND phase_type_id not in (13,14)) AND p.project_category_id = pcl.project_category_id -- Filter out the challenge that user is not belong to. AND (not exists (select contest_id from contest_eligibility where contest_id = p.project_id) diff --git a/routes.js b/routes.js index 9723cf149..e857d3f40 100755 --- a/routes.js +++ b/routes.js @@ -330,8 +330,8 @@ exports.routes = { { path: "/:apiVersion/data/srm/problems", action: "listSRMProblems" }, { path: "/:apiVersion/data/srm/rounds/:roundId/problems", action: "listRoundProblems" }, { path: "/:apiVersion/data/srm/rounds/:roundId/:problemId/:divisionId/components", action: "listRoundProblemComponents" }, - { path: "/:apiVersion/data/srm/rounds/:roundId/components", action: "listRoundProblemComponents" }, - { path: "/:apiVersion/data/srm/rounds/:contestId", action: "listSRMContestRounds" }, + { path: "/:apiVersion/data/srm/rounds/:roundId/components", action: "listRoundProblemComponents" }, + { path: "/:apiVersion/data/srm/rounds/:contestId", action: "listSRMContestRounds" }, { path: "/:apiVersion/auth0/callback", action: "auth0Callback" }, //Stubs APIs