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

Commit a5c0aba

Browse files
committed
merge
2 parents 24a03f6 + 4f7005c commit a5c0aba

File tree

5 files changed

+61
-5
lines changed

5 files changed

+61
-5
lines changed

actions/challenges.js

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved.
33
*
4-
* @version 1.18
4+
* @version 1.20
55
* @author Sky_, mekanizumu, TCSASSEMBLER, freegod, Ghost_141, kurtrips, xjtufreeman, ecnu_haozi, hesibo, LazyChild
66
* @changes from 1.0
77
* merged with Member Registration API
@@ -44,6 +44,10 @@
4444
* add API for submitting to design challenge
4545
* changes in 1.18:
4646
* add clientSelection flag in studio results
47+
* changes in 1.19:
48+
* add new allowed sort columns.
49+
* changes in 1.20:
50+
* add get challenge detail api for both design and develop challenge.
4751
*/
4852
"use strict";
4953
/*jslint stupid: true, unparam: true, continue: true */
@@ -90,7 +94,8 @@ var ALLOWABLE_QUERY_PARAMETER = [
9094
*/
9195
var ALLOWABLE_SORT_COLUMN = [
9296
"challengeName", "challengeType", "challengeId", "cmcTaskId", "registrationEndDate",
93-
"submissionEndDate", "finalFixEndDate", "prize1", "currentStatus", "digitalRunPoints"
97+
"submissionEndDate", "finalFixEndDate", "prize1", "currentStatus", "digitalRunPoints",
98+
"postingDate", "numSubmissions", "numRegistrants", "currentPhaseRemainingTime", "currentPhaseName", "registrationOpen"
9499
];
95100

96101
/**
@@ -329,7 +334,8 @@ function transferResult(src, helper) {
329334
digitalRunPoints: row.digital_run_points,
330335
prize: [],
331336
reliabilityBonus: helper.getReliabilityBonus(row.prize1),
332-
challengeCommunity: row.is_studio ? 'design' : 'develop'
337+
challengeCommunity: row.is_studio ? 'design' : 'develop',
338+
registrationOpen: row.registration_open
333339
});
334340

335341
for (i = 1; i < 10; i = i + 1) {
@@ -754,6 +760,10 @@ var getChallenge = function (api, connection, dbConnectionMap, isStudio, next) {
754760
submissionEndDate : formatDate(data.submission_end_date)
755761
};
756762

763+
if (connection.action === "getChallenge") {
764+
challenge.type = isStudio ? 'design' : 'develop';
765+
}
766+
757767
if (data.project_type === COPILOT_POSTING_PROJECT_TYPE && (isCopilot || helper.isAdmin(caller))) {
758768
challenge.copilotDetailedRequirements = data.copilot_detailed_requirements;
759769
}
@@ -1483,6 +1493,44 @@ exports.getStudioChallenge = {
14831493
}
14841494
};
14851495

1496+
/**
1497+
* The API for getting challenge details.
1498+
*
1499+
* @since 1.19
1500+
*/
1501+
exports.getChallenge = {
1502+
name: "getChallenge",
1503+
description: "getStudioChallenge",
1504+
inputs: {
1505+
required: ["contestId"],
1506+
optional: ["refresh"]
1507+
},
1508+
blockedConnectionTypes: [],
1509+
outputExample: {},
1510+
version: 'v2',
1511+
transaction: 'read', // this action is read-only
1512+
databases: ["tcs_catalog", "tcs_dw"],
1513+
run: function (api, connection, next) {
1514+
if (connection.dbConnectionMap) {
1515+
api.log("Execute getChallenge#run", 'debug');
1516+
api.dataAccess.executeQuery('check_challenge_exists', {challengeId: connection.params.contestId}, connection.dbConnectionMap, function (err, result) {
1517+
if (err) {
1518+
api.helper.handleError(api, connection, err);
1519+
next(connection, true);
1520+
} else if (result.length === 0) {
1521+
api.helper.handleError(api, connection, new NotFoundError("Challenge not found."));
1522+
next(connection, true);
1523+
} else {
1524+
var isStudio = Boolean(result[0].is_studio);
1525+
getChallenge(api, connection, connection.dbConnectionMap, isStudio, next);
1526+
}
1527+
});
1528+
} else {
1529+
api.helper.handleNoConnection(api, connection, next);
1530+
}
1531+
}
1532+
};
1533+
14861534
/**
14871535
* The API for searching challenges
14881536
*/

initializers/helper.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,13 @@ var apiName2dbNameMap = {
155155
numberofsubmissions: 'number_of_submissions',
156156
numberofreviewpositionsavailable: 'number_of_review_positions_available',
157157
round2scheduledstartdate: 'round_2_scheduled_start_date',
158-
round1scheduledstartdate: 'round_1_scheduled_start_date'
158+
round1scheduledstartdate: 'round_1_scheduled_start_date',
159+
postingdate: 'posting_date',
160+
numsubmissions: 'num_submissions',
161+
numregistrants: 'num_registrants',
162+
currentphaseremainingtime: 'current_phase_remaining_time',
163+
currentphasename: 'current_phase_name',
164+
registrationopen: 'registration_open'
159165
};
160166

161167
/**

queries/challenge_details

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ SELECT
5353
ELSE 0
5454
END AS current_phase_remaining_time
5555
, CASE WHEN pidr.value = 'On' THEN
56-
NVL((SELECT value::decimal FROM project_info pi_dr WHERE pi_dr.project_info_type_id = 30 AND pi_dr.project_id = p.project_id), (SELECT round(NVL(pi16.value::decimal, 0)) FROM project_info pi16 WHERE pi16.project_info_type_id = 16 AND pi16.project_id = p.project_id))
56+
NVL((SELECT value::decimal FROM project_info pi_dr WHERE pi_dr.project_info_type_id = 30 AND pi_dr.project_id = p.project_id), (SELECT round(NVL(pi16.value::decimal, 1)) FROM project_info pi16 WHERE pi16.project_info_type_id = 16 AND pi16.project_id = p.project_id))
5757
ELSE NULL END AS digital_run_points
5858
, pi51.value AS submission_limit
5959
, nvl((SELECT max(event_id) from contest_project_xref x, contest c where project_id = p.project_id and c.contest_id = x.contest_id), 0) as event_id

queries/search_software_studio_challenges

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ FIRST @pageSize@
4747
, (SELECT event_short_desc from event e where e.event_id = nvl((SELECT max(event_id) from contest_project_xref x, contest c where project_id = p.project_id and c.contest_id = x.contest_id), 0)) as event_name
4848
, technology_list(pi1.value) AS technology
4949
, platform_list(p.project_id) as platforms
50+
, CASE WHEN (pp1.phase_status_id = 2) THEN 'Yes' ELSE 'No' END AS registration_open
5051
FROM project p
5152
, project_status_lu pstatus
5253
, project_phase pp1 --registration phase

routes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ exports.routes = {
141141
get: [
142142
{ path: "/:apiVersion/logs", action: "getLogTail" },
143143
{ path: "/:apiVersion/challenges/rss", action: "getChallengesRSS" },
144+
{ path: "/:apiVersion/challenges/:contestId", action: "getChallenge" },
144145
{ path: "/:apiVersion/challenges", action: "searchSoftwareAndStudioChallenges" },
145146

146147
{ path: "/:apiVersion/develop/challenges/checkpoint/:challengeId", action: "getSoftwareCheckpoint" },

0 commit comments

Comments
 (0)