|
1 | 1 | /*
|
2 | 2 | * Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved.
|
3 | 3 | *
|
4 |
| - * @version 1.18 |
| 4 | + * @version 1.20 |
5 | 5 | * @author Sky_, mekanizumu, TCSASSEMBLER, freegod, Ghost_141, kurtrips, xjtufreeman, ecnu_haozi, hesibo, LazyChild
|
6 | 6 | * @changes from 1.0
|
7 | 7 | * merged with Member Registration API
|
|
44 | 44 | * add API for submitting to design challenge
|
45 | 45 | * changes in 1.18:
|
46 | 46 | * 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. |
47 | 51 | */
|
48 | 52 | "use strict";
|
49 | 53 | /*jslint stupid: true, unparam: true, continue: true */
|
@@ -90,7 +94,8 @@ var ALLOWABLE_QUERY_PARAMETER = [
|
90 | 94 | */
|
91 | 95 | var ALLOWABLE_SORT_COLUMN = [
|
92 | 96 | "challengeName", "challengeType", "challengeId", "cmcTaskId", "registrationEndDate",
|
93 |
| - "submissionEndDate", "finalFixEndDate", "prize1", "currentStatus", "digitalRunPoints" |
| 97 | + "submissionEndDate", "finalFixEndDate", "prize1", "currentStatus", "digitalRunPoints", |
| 98 | + "postingDate", "numSubmissions", "numRegistrants", "currentPhaseRemainingTime", "currentPhaseName", "registrationOpen" |
94 | 99 | ];
|
95 | 100 |
|
96 | 101 | /**
|
@@ -329,7 +334,8 @@ function transferResult(src, helper) {
|
329 | 334 | digitalRunPoints: row.digital_run_points,
|
330 | 335 | prize: [],
|
331 | 336 | reliabilityBonus: helper.getReliabilityBonus(row.prize1),
|
332 |
| - challengeCommunity: row.is_studio ? 'design' : 'develop' |
| 337 | + challengeCommunity: row.is_studio ? 'design' : 'develop', |
| 338 | + registrationOpen: row.registration_open |
333 | 339 | });
|
334 | 340 |
|
335 | 341 | for (i = 1; i < 10; i = i + 1) {
|
@@ -754,6 +760,10 @@ var getChallenge = function (api, connection, dbConnectionMap, isStudio, next) {
|
754 | 760 | submissionEndDate : formatDate(data.submission_end_date)
|
755 | 761 | };
|
756 | 762 |
|
| 763 | + if (connection.action === "getChallenge") { |
| 764 | + challenge.type = isStudio ? 'design' : 'develop'; |
| 765 | + } |
| 766 | + |
757 | 767 | if (data.project_type === COPILOT_POSTING_PROJECT_TYPE && (isCopilot || helper.isAdmin(caller))) {
|
758 | 768 | challenge.copilotDetailedRequirements = data.copilot_detailed_requirements;
|
759 | 769 | }
|
@@ -1483,6 +1493,44 @@ exports.getStudioChallenge = {
|
1483 | 1493 | }
|
1484 | 1494 | };
|
1485 | 1495 |
|
| 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 | + |
1486 | 1534 | /**
|
1487 | 1535 | * The API for searching challenges
|
1488 | 1536 | */
|
|
0 commit comments