Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit ce95c3f

Browse files
committed
Merge branch 'dev' of https://github.com/cloudspokes/tc-api into thabo-S-269146-identity-by-auth0-id
2 parents e8c8d81 + e098117 commit ce95c3f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1459
-204
lines changed

actions/bugs.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ var soap = require('soap');
1313
var https = require('https');
1414
var NotFoundError = require('../errors/NotFoundError');
1515

16-
//we must set this property, otherwise it's not possible to connect to jira service, due to some ssl issue
17-
https.globalAgent.options.secureProtocol = 'SSLv3_method';
1816

1917
/**
2018
* Max retires for soap authentication

actions/challengeRegistration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ var projectTrack = function (api, userId, challengeId, componentInfo, dbConnecti
306306
function (cb) {
307307
//Rating
308308
var rating = componentInfo.rating;
309-
309+
310310
if (rating > 0) {
311311
persistResourceInfo(api, resourceId, 4, componentInfo.rating, userId, dbConnectionMap, cb);
312312
} else {

actions/docusign.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ exports.generateDocusignViewURL = {
415415
});
416416
}
417417

418-
textTabs.push({tabLabel :'TopCoder Handle', value: user.handle});
418+
textTabs.push({tabLabel : 'TopCoder Handle', value: user.handle});
419419

420420
//Prepare the POST parameters
421421
reqParams = {
@@ -477,8 +477,7 @@ exports.generateDocusignViewURL = {
477477
var url, returnURL, reqParams;
478478

479479
//Create the return url
480-
returnURL = _.template(connection.params.returnUrl ?
481-
connection.params.returnUrl : api.config.tcConfig.docusign.returnURL)({envelopeId: envelopeId});
480+
returnURL = _.template(connection.params.returnUrl || api.config.tcConfig.docusign.returnURL)({envelopeId: envelopeId});
482481

483482
//Request recipient view
484483
url = baseURL + "/envelopes/" + envelopeId + "/views/recipient";

actions/reports.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ var clientChallengeCosts = function (api, connection, next) {
538538
cb(new NotFoundError('Client not found'));
539539
return;
540540
}
541-
if(type === helper.ListType.ACTIVE) {
541+
if (type === helper.ListType.ACTIVE) {
542542
api.dataAccess.executeQuery("active_client_challenges_costs", sqlParameters, dbConnectionMap, cb);
543543
} else {
544544
api.dataAccess.executeQuery("past_client_challenges_costs", sqlParameters, dbConnectionMap, cb);
@@ -649,8 +649,8 @@ exports.getClientActiveChallengeCosts = {
649649
api.dataAccess.executeQuery("get_client_active_challenge_costs", sqlParameters, dbConnectionMap, cb);
650650
}, function (results, cb) {
651651
costs = _.map(results, function (item) {
652-
var duration = item.challenge_duration ? parseFloat(item.challenge_duration.toFixed(1)) : 0;
653-
var currentPhaseText = item.current_phase;
652+
var duration = item.challenge_duration ? parseFloat(item.challenge_duration.toFixed(1)) : 0,
653+
currentPhaseText = item.current_phase;
654654
/* currentPhaseArray = [];
655655
656656
if (currentPhaseText) {

actions/rss.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function getChallengesRSS(api, connection, next) {
123123
techId = id;
124124
}
125125
if (!_.isUndefined(platforms)) {
126-
helper.getCatalogCachedValue(platforms.split(',').map(function (s) { return s.toLowerCase().toSource(); }), dbConnectionMap, 'platforms', cb);
126+
helper.getCatalogCachedValue(platforms.split(',').map(function (s) { return s.toLowerCase().toString(); }), dbConnectionMap, 'platforms', cb);
127127
} else {
128128
cb(null, null);
129129
}

actions/srmProblems.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var ForbiddenError = require('../errors/ForbiddenError');
3131
*/
3232
function parseProblem(item) {
3333
var type = {id: item.problem_type_id, description: item.problem_type_desc},
34-
status = {id: item.status_id, description: item.status_desc};
34+
status = {id: item.status_id, description: item.status_desc};
3535
return {id: item.problem_id, name: item.name, proposedDivisionId: item.division_id, type: type, status: status};
3636
}
3737

@@ -65,7 +65,7 @@ var listRoundProblems = function (api, connection, dbConnectionMap, next) {
6565
_.each(results, function (item) {
6666
var division = {id: item.division_id, desc: item.division_desc},
6767
problem = parseProblem(item);
68-
problem.roundId = roundId;
68+
problem.roundId = roundId;
6969
result.push({division: division, problemData: problem});
7070
});
7171

actions/srmRoundComponentsAndTerms.js

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function checkComponents(api, dbConnectionMap, components, callback) {
9999
}, function (results, cb) {
100100
if (!error) {
101101
if (results.length === 0) {
102-
error = new IllegalArgumentError("The componentId "+ component.componentId + " does not exist in database.");
102+
error = new IllegalArgumentError("The componentId " + component.componentId + " does not exist in database.");
103103
}
104104
}
105105

@@ -300,6 +300,47 @@ var setRoundTerms = function (api, connection, dbConnectionMap, next) {
300300
});
301301
};
302302

303+
/**
304+
* Gets round terms.
305+
*
306+
* @param api the api instance.
307+
* @param connection the connection instance
308+
* @param dbConnectionMap the database connection map
309+
* @param next the callback method
310+
*/
311+
var getRoundTerms = function (api, connection, dbConnectionMap, next) {
312+
var helper = api.helper,
313+
sqlParams = {},
314+
roundId = Number(connection.params.roundId),
315+
roundTermsContent = '';
316+
317+
async.waterfall([
318+
function (cb) {
319+
cb(helper.checkAdmin(connection, 'Authorized information needed.', 'Admin access only.'));
320+
}, function (cb) {
321+
cb(helper.checkIdParameter(roundId, "roundId"));
322+
}, function (cb) {
323+
sqlParams.round_id = roundId;
324+
api.dataAccess.executeQuery("get_round_terms", sqlParams, dbConnectionMap, cb);
325+
}, function (results, cb) {
326+
if (!results || results.length === 0) {
327+
var error = new IllegalArgumentError("The round terms can't be found with such roundId = " + roundId);
328+
cb(error);
329+
} else {
330+
roundTermsContent = results[0].terms_content;
331+
cb();
332+
}
333+
}
334+
], function (err) {
335+
if (err) {
336+
helper.handleError(api, connection, err);
337+
} else {
338+
connection.response = {"roundTermsContent": roundTermsContent};
339+
}
340+
next(connection, true);
341+
});
342+
};
343+
303344
/**
304345
* The API for Set Round Components.
305346
*/
@@ -348,4 +389,29 @@ exports.setRoundTerms = {
348389
api.helper.handleNoConnection(api, connection, next);
349390
}
350391
}
351-
};
392+
};
393+
394+
/**
395+
* The API for Get Round Terms.
396+
*/
397+
exports.getRoundTerms = {
398+
name: "getRoundTerms",
399+
description: "Get Round Terms",
400+
inputs: {
401+
required: ['roundId'],
402+
optional: []
403+
},
404+
blockedConnectionTypes: [],
405+
outputExample: {},
406+
version: 'v2',
407+
transaction: 'read',
408+
databases: ["informixoltp"],
409+
run: function (api, connection, next) {
410+
if (connection.dbConnectionMap) {
411+
api.log("Execute getRoundTerms#run", 'debug');
412+
getRoundTerms(api, connection, connection.dbConnectionMap, next);
413+
} else {
414+
api.helper.handleNoConnection(api, connection, next);
415+
}
416+
}
417+
};

actions/srmRoundManagement.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
/*
22
* Copyright (C) 2014 TopCoder Inc., All Rights Reserved.
3+
*/
4+
/**
5+
* Create, modify, list and delete SRM round.
36
*
4-
* @version 1.0
5-
* @author TCSASSEMBLER
7+
* Changes in version 1.1 (Module Assembly - Web Arena - Match Configurations):
8+
* - Updated ListSRMContestRounds to send UTC time in milliseconds for registration and coding start time
69
*
7-
* Create, modify, list and delete SRM round.
10+
* @version 1.1
11+
* @author TCSASSEMBLER
812
*/
913
/*jslint node: true, nomen: true */
1014
"use strict";
@@ -201,11 +205,13 @@ exports.listSRMContestRounds = {
201205
switch (segment.segment_id) {
202206
case 1:
203207
rr.registrationStart = helper.formatDateWithTimezone(formatDateTimeFromDB(segment.start_time));
208+
rr.registrationStartTime = start_time;
204209
rr.registrationLength = segment.duration;
205210
rr.registrationStatus = segment.status;
206211
break;
207212
case 2:
208213
rr.codingStart = helper.formatDateWithTimezone(formatDateTimeFromDB(segment.start_time));
214+
rr.codingStartTime = start_time;
209215
rr.codingLength = segment.duration;
210216
rr.codingStatus = segment.status;
211217
break;
@@ -430,18 +436,18 @@ exports.createSRMContestRound = {
430436
function (roundId, cbx) {
431437
params.id = roundId;
432438
api.dataAccess.executeQuery('insert_srm_contest_round',
433-
{
434-
contest_id: params.contest_id,
435-
round_id: params.id,
436-
round_type_id: params.type.id,
437-
registration_limit: params.registrationLimit,
438-
invitational: params.invitationalType,
439-
region_id: params.region.region_id,
440-
name: params.name,
441-
status: params.status,
442-
short_name: params.short_name
443-
},
444-
dbConnectionMap, cbx);
439+
{
440+
contest_id: params.contest_id,
441+
round_id: params.id,
442+
round_type_id: params.type.id,
443+
registration_limit: params.registrationLimit,
444+
invitational: params.invitationalType,
445+
region_id: params.region.region_id,
446+
name: params.name,
447+
status: params.status,
448+
short_name: params.short_name
449+
},
450+
dbConnectionMap, cbx);
445451
}
446452
], cb);
447453
},
@@ -781,4 +787,4 @@ exports.deleteSRMContestRound = {
781787
next(connection, true);
782788
});
783789
}
784-
};
790+
};

0 commit comments

Comments
 (0)