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

Commit fd08d91

Browse files
committed
Module Assembly - TopCoder NodeJS Apply Develop Review Opportunity API
1 parent 6336784 commit fd08d91

32 files changed

+1436
-115
lines changed

actions/challengeRegistration.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ var registerSoftwareChallengeAction = function (api, connection, next) {
594594
connection,
595595
challengeId,
596596
"Submitter", //optional value. Here we don't need to provide such value.
597+
true,
597598
connection.dbConnectionMap,
598599
cb
599600
);
@@ -644,6 +645,7 @@ var registerStudioChallengeAction = function (api, connection, next) {
644645
connection,
645646
challengeId,
646647
"Submitter",
648+
true,
647649
connection.dbConnectionMap,
648650
cb
649651
);

actions/challenges.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,7 @@ exports.getChallengeTerms = {
12561256
connection,
12571257
challengeId,
12581258
role,
1259+
true,
12591260
connection.dbConnectionMap,
12601261
cb
12611262
);

actions/reviewOpportunities.js

Lines changed: 337 additions & 2 deletions
Large diffs are not rendered by default.

apiary.apib

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,165 @@ Register a new user.
13381338
"description":"Servers are up but overloaded. Try again later."
13391339
}
13401340

1341+
1342+
## Apply Develop Review Opportunity Detail [/develop/reviewOpportunities/{challengeId}/apply]
1343+
### Apply Develop Review Opportunity Information [POST]
1344+
1345+
+ Request
1346+
1347+
Authorization : Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZHwxMzI0NTYiLCJleHAiOjEzOTQwODA3MTEsImF1ZCI6InRvcGNvZGVyIiwiaWF0IjoxMzk0MDIwNzExfQ.xaaaElykyAq3woRRkcFQSUK0gvKnRCOhCD57x070GJ4
1348+
1349+
+ Parameters
1350+
1351+
+ challengeId (required, number, `30000000`) ... The challenge id.
1352+
+ reviewApplicationRoleId (optional, number, `1`) ... The review application role id to apply.
1353+
1354+
+ Response 200 (application/json)
1355+
1356+
{
1357+
"message": "Your review application for this contest has been cancelled."
1358+
}
1359+
1360+
+ Response 200 (application/json)
1361+
1362+
{
1363+
"message": "You have successfully applied to review this contest. The system will automatically select reviewers that best match the review positions for this contest on 03.26.2014 08:00. You will be notified by email what review role you were assigned to."
1364+
}
1365+
1366+
+ Response 200 (application/json)
1367+
1368+
{
1369+
"message": "You have successfully applied to review this contest. The system will automatically decide whether you match the reviewer requirements for this contest now. You will be notified by email shortly."
1370+
}
1371+
1372+
+ Response 400 (application/json)
1373+
1374+
{
1375+
"name":"Bad Request",
1376+
"value":"400",
1377+
"description":"challengeId should be number."
1378+
}
1379+
1380+
+ Response 400 (application/json)
1381+
1382+
{
1383+
"name":"Bad Request",
1384+
"value":"400",
1385+
"description":"challengeId should be positive."
1386+
}
1387+
1388+
+ Response 400 (application/json)
1389+
1390+
{
1391+
"name":"Bad Request",
1392+
"value":"400",
1393+
"description":"challengeId should be Integer."
1394+
}
1395+
1396+
+ Response 400 (application/json)
1397+
1398+
{
1399+
"name":"Bad Request",
1400+
"value":"400",
1401+
"description":"challengeId should be less or equal to 2147483647."
1402+
}
1403+
1404+
+ Response 400 (application/json)
1405+
1406+
{
1407+
"name":"Bad Request",
1408+
"value":"400",
1409+
"description":"reviewApplicationRoleId should be an element of 1,2,3,4,5,6,7,8,9."
1410+
}
1411+
1412+
+ Response 400 (application/json)
1413+
1414+
{
1415+
"name":"Bad Request",
1416+
"value":"400",
1417+
"description":"The challenge is not existed or don't have any review opportunities or review registration is not open."
1418+
}
1419+
1420+
+ Response 400 (application/json)
1421+
1422+
{
1423+
"name":"Bad Request",
1424+
"value":"400",
1425+
"description":"You can't apply the review application role that do not belong to this challenge."
1426+
}
1427+
1428+
+ Response 403 (application/json)
1429+
1430+
{
1431+
"name":"Forbidden",
1432+
"value":"403",
1433+
"description":"You are not a Review Board member."
1434+
}
1435+
1436+
+ Response 400 (application/json)
1437+
1438+
{
1439+
"name":"Bad Request",
1440+
"value":"400",
1441+
"description":"You are already assigned as reviewer for the contest."
1442+
}
1443+
1444+
+ Response 400 (application/json)
1445+
1446+
{
1447+
"name":"Bad Request",
1448+
"value":"400",
1449+
"description":"There are no open positions for this challenge."
1450+
}
1451+
1452+
+ Response 400 (application/json)
1453+
1454+
{
1455+
"name":"Bad Request",
1456+
"value":"400",
1457+
"description":"There is no open positions for selected review application role: Primary Reviewer."
1458+
}
1459+
1460+
+ Response 403 (application/json)
1461+
1462+
{
1463+
"name":"Forbidden",
1464+
"value":"403",
1465+
"description":"You should agree with all terms of use."
1466+
}
1467+
1468+
+ Response 401 (application/json)
1469+
1470+
{
1471+
"name":"Unauthorized",
1472+
"value":"401",
1473+
"description":"Anonymous user don't have permission to access this api."
1474+
}
1475+
1476+
+ Response 403 (application/json)
1477+
1478+
{
1479+
"name":"Forbidden",
1480+
"value":"403",
1481+
"description":"The user is not allowed to register this challenge review."
1482+
}
1483+
1484+
+ Response 500 (application/json)
1485+
1486+
{
1487+
"name":"Internal Server Error",
1488+
"value":"500",
1489+
"description":"Unknown server error. Please contact support."
1490+
}
1491+
1492+
+ Response 503 (application/json)
1493+
1494+
{
1495+
"name":"Service Unavailable",
1496+
"value":"503",
1497+
"description":"Servers are up but overloaded. Try again later."
1498+
}
1499+
13411500

13421501
## Challenge Reviewers Collection [/develop/reviewers/{contestType}]
13431502
### List reviewers of current challenge type [GET]

initializers/challengeHelper.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
/*
22
* Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved.
33
*
4-
* @version 1.0
5-
* @author ecnu_haozi
4+
* @version 1.1
5+
* @author ecnu_haozi, Ghost_141
66
* Refactor common code out from challenge.js.
7+
* Changes in 1.1
8+
* - Add new parameter in getChallengeTerms.
79
*/
810
"use strict";
911

@@ -35,10 +37,11 @@ exports.challengeHelper = function (api, next) {
3537
* @param {Object} connection The connection object for the current request
3638
* @param {Number} challengeId The challenge id.
3739
* @param {String} role The user's role name, this is optional.
40+
* @param {Boolean} requireRegOpen - the flag that indicate need the challenge has open registration phase or not.
3841
* @param {Object} dbConnectionMap The database connection map for the current request
3942
* @param {Function<err, terms_array>} next The callback to be called after this function is done
4043
*/
41-
getChallengeTerms : function (connection, challengeId, role, dbConnectionMap, next) {
44+
getChallengeTerms : function (connection, challengeId, role, requireRegOpen, dbConnectionMap, next) {
4245

4346
//Check if the user is logged-in
4447
if (_.isUndefined(connection.caller) || _.isNull(connection.caller) ||
@@ -80,7 +83,8 @@ exports.challengeHelper = function (api, next) {
8083
return;
8184
}
8285

83-
if (!rows[0].reg_open) {
86+
// Update check to use flag.
87+
if (requireRegOpen && !rows[0].reg_open) {
8488
cb(new ForbiddenError('Registration Phase of this challenge is not open.'));
8589
return;
8690
}

initializers/helper.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
/**
77
* This module contains helper functions.
8-
* @author Sky_, Ghost_141, muzehyun, kurtrips, isv
9-
* @version 1.13
10-
* changes in 1.15
8+
* @author Sky_, Ghost_141, muzehyun, kurtrips, isv, TCSASSEMBLER
9+
* @version 1.16
10+
* changes in 1.1
1111
* - add mapProperties
1212
* changes in 1.2:
1313
* - add getPercent to underscore mixin
@@ -48,6 +48,8 @@
4848
* - add method checkMember to check if the caller have at least member access leve.
4949
* changes in 1.15
5050
* - added checkUserExists function
51+
* Changes in 1.16:
52+
* - add allTermsAgreed method.
5153
*/
5254
"use strict";
5355

@@ -928,9 +930,9 @@ helper.getPhaseId = function (phaseName) {
928930
*/
929931
helper.getColorStyle = function (rating) {
930932

931-
if (rating === null) {
932-
return "color: #000000";
933-
}
933+
if (rating === null) {
934+
return "color: #000000";
935+
}
934936

935937
if (rating < 0) {
936938
return "color: #FF9900"; // orange
@@ -1132,6 +1134,18 @@ helper.checkUserExists = function (handle, api, dbConnectionMap, callback) {
11321134
});
11331135
};
11341136

1137+
/**
1138+
* check if the every terms has been agreed
1139+
*
1140+
* @param {Array} terms - The terms.
1141+
* @returns {Boolean} true if all terms agreed otherwise false.
1142+
* @since 1.16
1143+
*/
1144+
helper.allTermsAgreed = function (terms) {
1145+
return _.every(terms, function (term) {
1146+
return term.agreed;
1147+
});
1148+
};
11351149

11361150
/**
11371151
* Expose the "helper" utility.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
SELECT
2-
(project_id IS NOT NULL) as challenge_is_copilot
3-
FROM project p
4-
WHERE p.project_id = @challengeId@
5-
AND p.project_category_id = 29
1+
SELECT
2+
(project_id IS NOT NULL) as challenge_is_copilot
3+
FROM project p
4+
WHERE p.project_id = @challengeId@
5+
AND p.project_category_id = 29
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{
2-
"name" : "check_challenge_is_copilot_posting",
3-
"db" : "tcs_catalog",
4-
"sqlfile" : "check_challenge_is_copilot_posting"
1+
{
2+
"name" : "check_challenge_is_copilot_posting",
3+
"db" : "tcs_catalog",
4+
"sqlfile" : "check_challenge_is_copilot_posting"
55
}

queries/check_reviewer

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT 1
2+
FROM rboard_user ru
3+
INNER JOIN project p ON ru.project_type_id = p.project_category_id
4+
WHERE ru.user_id = @user_id@
5+
AND ru.status_id = 100
6+
AND p.project_id = @challenge_id@

queries/check_reviewer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name" : "check_reviewer",
3+
"db" : "tcs_catalog",
4+
"sqlfile" : "check_reviewer"
5+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
SELECT
2+
DISTINCT
3+
r.resource_role_id
4+
, u.user_id
5+
FROM resource r
6+
INNER JOIN resource_info ri ON r.resource_id = ri.resource_id AND ri.resource_info_type_id = 1
7+
INNER JOIN user u ON u.user_id = ri.value
8+
INNER JOIN review_auction ra ON ra.project_id = r.project_id
9+
INNER JOIN review_application_role_lu rarl ON rarl.review_auction_type_id = ra.review_auction_type_id
10+
INNER JOIN review_application_role_resource_role_xref rarrrx ON rarrrx.review_application_role_id = rarl.review_application_role_id AND rarrrx.resource_role_id = r.resource_role_id
11+
WHERE r.project_id = @challenge_id@
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name" : "get_assigned_review_resource_role",
3+
"db" : "tcs_catalog",
4+
"sqlfile" : "get_assigned_review_resource_role"
5+
}

queries/get_next_sequence_tcs_catalog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select SEQUENCE_@seq_name@.NEXTVAL as next_id from table(set{1})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name" : "get_next_sequence_tcs_catalog",
3+
"db" : "tcs_catalog",
4+
"sqlfile" : "get_next_sequence_tcs_catalog"
5+
}

queries/get_user_review_applications

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
SELECT
2+
rarl.name AS role
3+
, rarl.review_application_role_id AS role_id
4+
, ra.review_application_id
5+
, rasl.name AS status
6+
FROM review_application ra
7+
INNER JOIN user u ON u.user_id = ra.user_id
8+
INNER JOIN review_auction rauc ON rauc.review_auction_id = ra.review_auction_id AND rauc.project_id = @challenge_id@
9+
INNER JOIN review_application_role_lu rarl ON rarl.review_application_role_id = ra.review_application_role_id
10+
INNER JOIN review_application_status_lu rasl ON rasl.review_application_status_id = ra.review_application_status_id
11+
WHERE u.user_id = @user_id@
12+
ORDER BY ra.create_date ASC
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name" : "get_user_review_applications",
3+
"db" : "tcs_catalog",
4+
"sqlfile" : "get_user_review_applications"
5+
}

queries/insert_resource

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
INSERT INTO resource
2-
( resource_id,
3-
resource_role_id,
4-
project_id,
5-
user_id,
6-
create_user,
7-
create_date,
8-
modify_user,
9-
modify_date)
10-
VALUES
11-
( @resourceId@,
12-
1,
13-
@projectId@,
14-
@userId@,
15-
@createUser@,
16-
CURRENT,
17-
@modifyUser@,
18-
CURRENT
1+
INSERT INTO resource
2+
( resource_id,
3+
resource_role_id,
4+
project_id,
5+
user_id,
6+
create_user,
7+
create_date,
8+
modify_user,
9+
modify_date)
10+
VALUES
11+
( @resourceId@,
12+
1,
13+
@projectId@,
14+
@userId@,
15+
@createUser@,
16+
CURRENT,
17+
@modifyUser@,
18+
CURRENT
1919
)

0 commit comments

Comments
 (0)