From 24b007a421cbf81543291a9e6c1b67462a8f3ddf Mon Sep 17 00:00:00 2001 From: ananthhh Date: Fri, 24 Oct 2014 12:04:55 +0530 Subject: [PATCH 1/2] FF Commit --- actions/srmRoundManagement.js | 14 ++++++++++---- actions/srmRoundQuestions.js | 15 +++++++++------ actions/srmRoundSegments.js | 32 +++++++++++++++++++------------- routes.js | 20 +++----------------- 4 files changed, 41 insertions(+), 40 deletions(-) diff --git a/actions/srmRoundManagement.js b/actions/srmRoundManagement.js index 64924dca3..fdff5a62d 100644 --- a/actions/srmRoundManagement.js +++ b/actions/srmRoundManagement.js @@ -1,10 +1,14 @@ /* * Copyright (C) 2014 TopCoder Inc., All Rights Reserved. + */ +/** + * Create, modify, list and delete SRM round. * - * @version 1.0 - * @author TCSASSEMBLER + * Changes in version 1.1 (Module Assembly - Web Arena - Match Configurations): + * - Updated ListSRMContestRounds to send UTC time in milliseconds for registration and coding start time * - * Create, modify, list and delete SRM round. + * @version 1.1 + * @author TCSASSEMBLER */ /*jslint node: true, nomen: true */ "use strict"; @@ -201,11 +205,13 @@ exports.listSRMContestRounds = { switch (segment.segment_id) { case 1: rr.registrationStart = helper.formatDateWithTimezone(formatDateTimeFromDB(segment.start_time)); + rr.registrationStartTime = start_time; rr.registrationLength = segment.duration; rr.registrationStatus = segment.status; break; case 2: rr.codingStart = helper.formatDateWithTimezone(formatDateTimeFromDB(segment.start_time)); + rr.codingStartTime = start_time; rr.codingLength = segment.duration; rr.codingStatus = segment.status; break; @@ -781,4 +787,4 @@ exports.deleteSRMContestRound = { next(connection, true); }); } -}; \ No newline at end of file +}; diff --git a/actions/srmRoundQuestions.js b/actions/srmRoundQuestions.js index 27ef3a561..4535affe6 100644 --- a/actions/srmRoundQuestions.js +++ b/actions/srmRoundQuestions.js @@ -1,10 +1,13 @@ /* * Copyright (C) 2014 TopCoder Inc., All Rights Reserved. + */ + /** + * - Implement the srm round questions / answers / survey api. + * Changes in version 1.1 (Module Assembly - Web Arena - Match Configurations): + * - Updated getRoundQuestions to send roundId with response * - * @version 1.0 + * @version 1.1 * @author TCSASSEMBLER - * - * - Implement the srm round questions / answers / survey api. */ /*jslint node: true, nomen: true, plusplus: true, stupid: true, unparam: true */ @@ -94,7 +97,7 @@ var getRoundQuestions = function (api, connection, dbConnectionMap, next) { if (err) { helper.handleError(api, connection, err); } else { - connection.response = {questions: result}; + connection.response = {questions: result, roundId: roundId}; } next(connection, true); }); @@ -544,7 +547,7 @@ var addRoundQuestion = function (api, connection, dbConnectionMap, next) { if (err) { helper.handleError(api, connection, err); } else { - connection.response = {"success": true}; + connection.response = {"success": true, questionId: questionId}; } next(connection, true); }); @@ -744,4 +747,4 @@ exports.modifyRoundQuestion = { api.helper.handleNoConnection(api, connection, next); } } -}; \ No newline at end of file +}; diff --git a/actions/srmRoundSegments.js b/actions/srmRoundSegments.js index aafce1629..4ec57c083 100644 --- a/actions/srmRoundSegments.js +++ b/actions/srmRoundSegments.js @@ -1,10 +1,14 @@ /* * Copyright (C) 2014 TopCoder Inc., All Rights Reserved. + */ +/** + * Implement the srm round segments api. + * + * Changes in version 1.1 (Module Assembly - Web Arena - Match Configurations): + * - Modified date format and make it norm to include timezone so that moment.js can parse time correctly * - * @version 1.0 + * @version 1.1 * @author TCSASSEMBLER - * - * - Implement the srm round segments api. */ /*jslint node: true, nomen: true, plusplus: true, stupid: true, unparam: true */ @@ -14,8 +18,8 @@ var _ = require('underscore'); var moment = require('moment'); var IllegalArgumentError = require('../errors/IllegalArgumentError'); -var DATE_FORMAT = "YYYY-MM-DD HH:mm:ss"; - +var DATE_FORMAT = "YYYY-MM-DD HH:mm:ssZZ"; +var DB_DATE_FORMAT = "YYYY-MM-DD HH:mm:ss"; /** * Check round id. * @@ -169,34 +173,36 @@ var setRoundSegments = function (api, connection, dbConnectionMap, next) { cb(error); } }, function (results, cb) { - sqlParams.startTime = helper.formatDate(registrationStart, DATE_FORMAT); - sqlParams.endTime = moment(registrationStart, DATE_FORMAT).add('minutes', registrationLength).format(DATE_FORMAT); + sqlParams.startTime = helper.formatDate(registrationStart, DB_DATE_FORMAT); + api.log(sqlParams.startTime); + sqlParams.endTime = moment(registrationStart, DATE_FORMAT).add('minutes', registrationLength).format(DB_DATE_FORMAT); + sqlParams.segmentId = helper.SEGMENTS_ID_MAP.REGISTRATION_PHASE; sqlParams.status = registrationStatus; sqlParams.roundId = roundId; api.dataAccess.executeQuery("insert_round_segments", sqlParams, dbConnectionMap, cb); }, function (results, cb) { //the registration end time plus 1 minute - sqlParams.startTime = moment(sqlParams.endTime, DATE_FORMAT).add('minutes', 1).format(DATE_FORMAT); - sqlParams.endTime = helper.formatDate(codingStart, DATE_FORMAT); + sqlParams.startTime = moment(sqlParams.endTime, DB_DATE_FORMAT).add('minutes', 1).format(DB_DATE_FORMAT); + sqlParams.endTime = helper.formatDate(codingStart, DB_DATE_FORMAT); sqlParams.segmentId = helper.SEGMENTS_ID_MAP.ROOM_ASSIGNMENT_PHASE; sqlParams.status = registrationStatus; api.dataAccess.executeQuery("insert_round_segments", sqlParams, dbConnectionMap, cb); }, function (results, cb) { sqlParams.startTime = sqlParams.endTime; - sqlParams.endTime = moment(sqlParams.startTime, DATE_FORMAT).add('minutes', codingLength).format(DATE_FORMAT); + sqlParams.endTime = moment(sqlParams.startTime, DB_DATE_FORMAT).add('minutes', codingLength).format(DB_DATE_FORMAT); sqlParams.segmentId = helper.SEGMENTS_ID_MAP.CODING_PHASE; sqlParams.status = codingStatus; api.dataAccess.executeQuery("insert_round_segments", sqlParams, dbConnectionMap, cb); }, function (results, cb) { sqlParams.startTime = sqlParams.endTime; - sqlParams.endTime = moment(sqlParams.startTime, DATE_FORMAT).add('minutes', intermissionLength).format(DATE_FORMAT); + sqlParams.endTime = moment(sqlParams.startTime, DB_DATE_FORMAT).add('minutes', intermissionLength).format(DB_DATE_FORMAT); sqlParams.segmentId = helper.SEGMENTS_ID_MAP.INTERMISSION_PHASE; sqlParams.status = intermissionStatus; api.dataAccess.executeQuery("insert_round_segments", sqlParams, dbConnectionMap, cb); }, function (results, cb) { sqlParams.startTime = sqlParams.endTime; - sqlParams.endTime = moment(sqlParams.startTime, DATE_FORMAT).add('minutes', challengeLength).format(DATE_FORMAT); + sqlParams.endTime = moment(sqlParams.startTime, DB_DATE_FORMAT).add('minutes', challengeLength).format(DB_DATE_FORMAT); sqlParams.segmentId = helper.SEGMENTS_ID_MAP.CHALLENGE_PHASE; sqlParams.status = challengeStatus; api.dataAccess.executeQuery("insert_round_segments", sqlParams, dbConnectionMap, cb); @@ -241,4 +247,4 @@ exports.setRoundSegments = { api.helper.handleNoConnection(api, connection, next); } } -}; \ No newline at end of file +}; diff --git a/routes.js b/routes.js index 9723cf149..75907dcaf 100755 --- a/routes.js +++ b/routes.js @@ -1,7 +1,7 @@ /* * Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved. * - * @version 1.60 + * @version 1.56 * @author vangavroche, Sky_, muzehyun, kurtrips, Ghost_141, ecnu_haozi, hesibo, LazyChild, isv, flytoj2ee, * @author panoptimum, bugbuka, Easyhard * @@ -132,14 +132,6 @@ * - Add routes for set round components and terms. * Changes in 1.56: * - Add route for Data Science Past Challenges API. - * Changes in 1.57 (Module Assembly - Topcoder NodeJS Active and Upcoming Data Science Challenge API): - * - Added route for Active / Upcoming Data Science Challenges API. - * Changes in 1.58: - * - Add routes for SRM practice problems API. - * Changes in 1.59: - * - Add route for user activation email api. - * Changes in 1.60: - * - Add route for get user identity api. */ /*jslint node:true, nomen: true */ "use strict"; @@ -255,8 +247,6 @@ exports.routes = { { path: "/:apiVersion/design/download/:submissionId", action: "downloadDesignSubmission" }, { path: "/:apiVersion/user/challenges", action: "getMyChallenges" }, - { path: "/:apiVersion/user/activation-email", action: "userActivationEmail" }, - { path: "/:apiVersion/user/identity", action: "getUserIdentity" }, { path: "/:apiVersion/users/tops/:trackType", action: "getTopTrackMembers" }, { path: "/:apiVersion/users/resetToken", action: "generateResetToken" }, @@ -281,7 +271,6 @@ exports.routes = { { path: "/:apiVersion/data/srm/challenges", action: "searchSRMChallenges" }, { path: "/:apiVersion/data/srm/roundAccess", action: "loadRoundAccess"}, { path: "/:apiVersion/data/srm/schedule", action: "getSRMSchedule"}, - { path: "/:apiVersion/data/srm/practice/problems", action: "getPracticeProblems" }, { path: "/:apiVersion/data/marathon/challenges/:roundId/regInfo", action: "getMarathonChallengeRegInfo" }, { path: "/:apiVersion/data/marathon/challenges/:id", action: "getMarathonChallenge" }, @@ -295,8 +284,6 @@ exports.routes = { { path: "/:apiVersion/terms/detail/:termsOfUseId", action: "getTermsOfUse"}, { path: "/:apiVersion/data/srm/contests", action: "listSRMContests"}, { path: "/:apiVersion/dataScience/challenges/past", action: "pastDataScienceChallenges"}, - { path: "/:apiVersion/dataScience/challenges/active", action: "activeDataScienceChallenges"}, - { path: "/:apiVersion/dataScience/challenges/upcoming", action: "upcomingDataScienceChallenges"}, //example secure route using oauth. for future reference. { path: "/:apiVersion/secure/challengetypes", action: "softwareTypesSecured" }, @@ -374,7 +361,7 @@ exports.routes = { { path: "/:apiVersion/data/srm/rounds/:roundId/segments", action: "setRoundSegments"}, { path: "/:apiVersion/data/srm/rounds/:roundId/survey", action: "setRoundSurvey"}, { path: "/:apiVersion/data/srm/questions/:questionId/answers", action: "addRoundQuestionAnswer"}, - + { path: "/:apiVersion/data/srm/rounds/:questionId/question", action: "modifyRoundQuestion"}, { path: "/:apiVersion/data/srm/rounds/:roundId/components", action: "setRoundComponents"}, { path: "/:apiVersion/data/srm/rounds/:roundId/terms", action: "setRoundTerms"}, { path: "/:apiVersion/data/srm/rounds", action: "createSRMContestRound" } @@ -382,8 +369,7 @@ exports.routes = { put: [ { path: "/:apiVersion/data/srm/contests/:id", action: "updateSRMContest"}, - { path: "/:apiVersion/data/srm/rounds/:oldRoundId", action: "modifySRMContestRound" }, - { path: "/:apiVersion/data/srm/rounds/:questionId/question", action: "modifyRoundQuestion"} + { path: "/:apiVersion/data/srm/rounds/:oldRoundId", action: "modifySRMContestRound" } ], delete: [ { path: "/:apiVersion/data/srm/rounds/:roundId", action: "deleteSRMContestRound" } From 96472a69c434013ad3504e45b0a9c9d97d7c5602 Mon Sep 17 00:00:00 2001 From: ananthhh Date: Fri, 24 Oct 2014 12:13:18 +0530 Subject: [PATCH 2/2] Fixed merge problems --- actions/srmRoundSegments.js | 1 - routes.js | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/actions/srmRoundSegments.js b/actions/srmRoundSegments.js index 4ec57c083..706788496 100644 --- a/actions/srmRoundSegments.js +++ b/actions/srmRoundSegments.js @@ -174,7 +174,6 @@ var setRoundSegments = function (api, connection, dbConnectionMap, next) { } }, function (results, cb) { sqlParams.startTime = helper.formatDate(registrationStart, DB_DATE_FORMAT); - api.log(sqlParams.startTime); sqlParams.endTime = moment(registrationStart, DATE_FORMAT).add('minutes', registrationLength).format(DB_DATE_FORMAT); sqlParams.segmentId = helper.SEGMENTS_ID_MAP.REGISTRATION_PHASE; diff --git a/routes.js b/routes.js index 25fc1360e..89ffd8881 100755 --- a/routes.js +++ b/routes.js @@ -1,7 +1,7 @@ /* * Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved. * - * @version 1.56 + * @version 1.60 * @author vangavroche, Sky_, muzehyun, kurtrips, Ghost_141, ecnu_haozi, hesibo, LazyChild, isv, flytoj2ee, * @author panoptimum, bugbuka, Easyhard * @@ -132,6 +132,14 @@ * - Add routes for set round components and terms. * Changes in 1.56: * - Add route for Data Science Past Challenges API. + * Changes in 1.57 (Module Assembly - Topcoder NodeJS Active and Upcoming Data Science Challenge API): + * - Added route for Active / Upcoming Data Science Challenges API. + * Changes in 1.58: + * - Add routes for SRM practice problems API. + * Changes in 1.59: + * - Add route for user activation email api. + * Changes in 1.60: + * - Add route for get user identity api. */ /*jslint node:true, nomen: true */ "use strict"; @@ -247,6 +255,8 @@ exports.routes = { { path: "/:apiVersion/design/download/:submissionId", action: "downloadDesignSubmission" }, { path: "/:apiVersion/user/challenges", action: "getMyChallenges" }, + { path: "/:apiVersion/user/activation-email", action: "userActivationEmail" }, + { path: "/:apiVersion/user/identity", action: "getUserIdentity" }, { path: "/:apiVersion/users/tops/:trackType", action: "getTopTrackMembers" }, { path: "/:apiVersion/users/resetToken", action: "generateResetToken" }, @@ -271,6 +281,7 @@ exports.routes = { { path: "/:apiVersion/data/srm/challenges", action: "searchSRMChallenges" }, { path: "/:apiVersion/data/srm/roundAccess", action: "loadRoundAccess"}, { path: "/:apiVersion/data/srm/schedule", action: "getSRMSchedule"}, + { path: "/:apiVersion/data/srm/practice/problems", action: "getPracticeProblems" }, { path: "/:apiVersion/data/marathon/challenges/:roundId/regInfo", action: "getMarathonChallengeRegInfo" }, { path: "/:apiVersion/data/marathon/challenges/:id", action: "getMarathonChallenge" }, @@ -284,6 +295,8 @@ exports.routes = { { path: "/:apiVersion/terms/detail/:termsOfUseId", action: "getTermsOfUse"}, { path: "/:apiVersion/data/srm/contests", action: "listSRMContests"}, { path: "/:apiVersion/dataScience/challenges/past", action: "pastDataScienceChallenges"}, + { path: "/:apiVersion/dataScience/challenges/active", action: "activeDataScienceChallenges"}, + { path: "/:apiVersion/dataScience/challenges/upcoming", action: "upcomingDataScienceChallenges"}, //example secure route using oauth. for future reference. { path: "/:apiVersion/secure/challengetypes", action: "softwareTypesSecured" },