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

Commit b826873

Browse files
committed
Merge pull request #182 from Ghost141/apply_review
Apply Develop Review Opportunity API
2 parents 3e535dd + 89e9f97 commit b826873

28 files changed

+1331
-8
lines changed

actions/challengeRegistration.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ var registerSoftwareChallengeAction = function (api, connection, next) {
676676
connection,
677677
challengeId,
678678
"Submitter", //optional value. Here we don't need to provide such value.
679+
true,
679680
connection.dbConnectionMap,
680681
cb
681682
);
@@ -726,6 +727,7 @@ var registerStudioChallengeAction = function (api, connection, next) {
726727
connection,
727728
challengeId,
728729
"Submitter",
730+
true,
729731
connection.dbConnectionMap,
730732
cb
731733
);

actions/challenges.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,7 @@ exports.getChallengeTerms = {
12511251
connection,
12521252
challengeId,
12531253
role,
1254+
true,
12541255
connection.dbConnectionMap,
12551256
cb
12561257
);

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
@@ -1670,6 +1670,165 @@ Register a new user.
16701670
"description":"Servers are up but overloaded. Try again later."
16711671
}
16721672

1673+
1674+
## Apply Develop Review Opportunity Detail [/develop/reviewOpportunities/{challengeId}/apply]
1675+
### Apply Develop Review Opportunity Information [POST]
1676+
1677+
+ Request
1678+
1679+
Authorization : Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZHwxMzI0NTYiLCJleHAiOjEzOTQwODA3MTEsImF1ZCI6InRvcGNvZGVyIiwiaWF0IjoxMzk0MDIwNzExfQ.xaaaElykyAq3woRRkcFQSUK0gvKnRCOhCD57x070GJ4
1680+
1681+
+ Parameters
1682+
1683+
+ challengeId (required, number, `30000000`) ... The challenge id.
1684+
+ reviewApplicationRoleId (optional, number, `1`) ... The review application role id to apply.
1685+
1686+
+ Response 200 (application/json)
1687+
1688+
{
1689+
"message": "Your review application for this contest has been cancelled."
1690+
}
1691+
1692+
+ Response 200 (application/json)
1693+
1694+
{
1695+
"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."
1696+
}
1697+
1698+
+ Response 200 (application/json)
1699+
1700+
{
1701+
"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."
1702+
}
1703+
1704+
+ Response 400 (application/json)
1705+
1706+
{
1707+
"name":"Bad Request",
1708+
"value":"400",
1709+
"description":"challengeId should be number."
1710+
}
1711+
1712+
+ Response 400 (application/json)
1713+
1714+
{
1715+
"name":"Bad Request",
1716+
"value":"400",
1717+
"description":"challengeId should be positive."
1718+
}
1719+
1720+
+ Response 400 (application/json)
1721+
1722+
{
1723+
"name":"Bad Request",
1724+
"value":"400",
1725+
"description":"challengeId should be Integer."
1726+
}
1727+
1728+
+ Response 400 (application/json)
1729+
1730+
{
1731+
"name":"Bad Request",
1732+
"value":"400",
1733+
"description":"challengeId should be less or equal to 2147483647."
1734+
}
1735+
1736+
+ Response 400 (application/json)
1737+
1738+
{
1739+
"name":"Bad Request",
1740+
"value":"400",
1741+
"description":"reviewApplicationRoleId should be an element of 1,2,3,4,5,6,7,8,9."
1742+
}
1743+
1744+
+ Response 400 (application/json)
1745+
1746+
{
1747+
"name":"Bad Request",
1748+
"value":"400",
1749+
"description":"The challenge is not existed or don't have any review opportunities or review registration is not open."
1750+
}
1751+
1752+
+ Response 400 (application/json)
1753+
1754+
{
1755+
"name":"Bad Request",
1756+
"value":"400",
1757+
"description":"You can't apply the review application role that do not belong to this challenge."
1758+
}
1759+
1760+
+ Response 403 (application/json)
1761+
1762+
{
1763+
"name":"Forbidden",
1764+
"value":"403",
1765+
"description":"You are not a Review Board member."
1766+
}
1767+
1768+
+ Response 400 (application/json)
1769+
1770+
{
1771+
"name":"Bad Request",
1772+
"value":"400",
1773+
"description":"You are already assigned as reviewer for the contest."
1774+
}
1775+
1776+
+ Response 400 (application/json)
1777+
1778+
{
1779+
"name":"Bad Request",
1780+
"value":"400",
1781+
"description":"There are no open positions for this challenge."
1782+
}
1783+
1784+
+ Response 400 (application/json)
1785+
1786+
{
1787+
"name":"Bad Request",
1788+
"value":"400",
1789+
"description":"There is no open positions for selected review application role: Primary Reviewer."
1790+
}
1791+
1792+
+ Response 403 (application/json)
1793+
1794+
{
1795+
"name":"Forbidden",
1796+
"value":"403",
1797+
"description":"You should agree with all terms of use."
1798+
}
1799+
1800+
+ Response 401 (application/json)
1801+
1802+
{
1803+
"name":"Unauthorized",
1804+
"value":"401",
1805+
"description":"Anonymous user don't have permission to access this api."
1806+
}
1807+
1808+
+ Response 403 (application/json)
1809+
1810+
{
1811+
"name":"Forbidden",
1812+
"value":"403",
1813+
"description":"The user is not allowed to register this challenge review."
1814+
}
1815+
1816+
+ Response 500 (application/json)
1817+
1818+
{
1819+
"name":"Internal Server Error",
1820+
"value":"500",
1821+
"description":"Unknown server error. Please contact support."
1822+
}
1823+
1824+
+ Response 503 (application/json)
1825+
1826+
{
1827+
"name":"Service Unavailable",
1828+
"value":"503",
1829+
"description":"Servers are up but overloaded. Try again later."
1830+
}
1831+
16731832

16741833
## Challenge Reviewers Collection [/develop/reviewers/{contestType}]
16751834
### 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,12 +1,14 @@
11
/*
22
* Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved.
33
*
4-
* @version 1.1
5-
* @author ecnu_haozi, bugbuka
4+
* @version 1.2
5+
* @author ecnu_haozi, bugbuka, Ghost_141
66
* Refactor common code out from challenge.js.
77
*
88
* changes in 1.1:
99
* add common function getForumWrapper, aduitResourceAddition
10+
* Changes in 1.2:
11+
* - Add new parameter in getChallengeTerms.
1012
*/
1113
"use strict";
1214

@@ -88,10 +90,11 @@ exports.challengeHelper = function (api, next) {
8890
* @param {Object} connection The connection object for the current request
8991
* @param {Number} challengeId The challenge id.
9092
* @param {String} role The user's role name, this is optional.
93+
* @param {Boolean} requireRegOpen - the flag that indicate need the challenge has open registration phase or not.
9194
* @param {Object} dbConnectionMap The database connection map for the current request
9295
* @param {Function<err, terms_array>} next The callback to be called after this function is done
9396
*/
94-
getChallengeTerms : function (connection, challengeId, role, dbConnectionMap, next) {
97+
getChallengeTerms : function (connection, challengeId, role, requireRegOpen, dbConnectionMap, next) {
9598

9699
//Check if the user is logged-in
97100
if (_.isUndefined(connection.caller) || _.isNull(connection.caller) ||
@@ -133,7 +136,8 @@ exports.challengeHelper = function (api, next) {
133136
return;
134137
}
135138

136-
if (!rows[0].reg_open) {
139+
// Update check to use flag.
140+
if (requireRegOpen && !rows[0].reg_open) {
137141
cb(new ForbiddenError('Registration Phase of this challenge is not open.'));
138142
return;
139143
}

initializers/helper.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/**
77
* This module contains helper functions.
88
* @author Sky_, Ghost_141, muzehyun, kurtrips, isv, LazyChild, hesibo
9-
* @version 1.21
9+
* @version 1.22
1010
* changes in 1.1:
1111
* - add mapProperties
1212
* changes in 1.2:
@@ -60,6 +60,8 @@
6060
* - added activation code generation function (copied from memberRegistration.js)
6161
* Changes in 1.21:
6262
* - add LIST_TYPE_REGISTRATION_STATUS_MAP and VALID_LIST_TYPE.
63+
* Changes in 1.22:
64+
* - add allTermsAgreed method.
6365
*/
6466
"use strict";
6567

@@ -1195,6 +1197,19 @@ helper.checkUserExists = function (handle, api, dbConnectionMap, callback) {
11951197
});
11961198
};
11971199

1200+
/**
1201+
* check if the every terms has been agreed
1202+
*
1203+
* @param {Array} terms - The terms.
1204+
* @returns {Boolean} true if all terms agreed otherwise false.
1205+
* @since 1.16
1206+
*/
1207+
helper.allTermsAgreed = function (terms) {
1208+
return _.every(terms, function (term) {
1209+
return term.agreed;
1210+
});
1211+
};
1212+
11981213
/**
11991214
* Gets all file types and caches them.
12001215
* @param {Object} api - the action hero api object

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
INSERT INTO resource
2-
( resource_id,
2+
( resource_id,
33
resource_role_id,
44
project_id,
55
user_id,

queries/insert_review_application

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
INSERT INTO review_application(review_application_id, user_id, review_auction_id, review_application_role_id, review_application_status_id, create_date, modify_date)
2+
VALUES(@review_application_id@, @user_id@, @review_auction_id@, @role_id@, @status@, current, current)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name" : "insert_review_application",
3+
"db" : "tcs_catalog",
4+
"sqlfile" : "insert_review_application"
5+
}

0 commit comments

Comments
 (0)