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

Apply Develop Review Opportunity API #182

Merged
merged 2 commits into from
Apr 9, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions actions/challengeRegistration.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ var registerSoftwareChallengeAction = function (api, connection, next) {
connection,
challengeId,
"Submitter", //optional value. Here we don't need to provide such value.
true,
connection.dbConnectionMap,
cb
);
Expand Down Expand Up @@ -726,6 +727,7 @@ var registerStudioChallengeAction = function (api, connection, next) {
connection,
challengeId,
"Submitter",
true,
connection.dbConnectionMap,
cb
);
Expand Down
1 change: 1 addition & 0 deletions actions/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,7 @@ exports.getChallengeTerms = {
connection,
challengeId,
role,
true,
connection.dbConnectionMap,
cb
);
Expand Down
339 changes: 337 additions & 2 deletions actions/reviewOpportunities.js

Large diffs are not rendered by default.

159 changes: 159 additions & 0 deletions apiary.apib
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,165 @@ Register a new user.
"description":"Servers are up but overloaded. Try again later."
}


## Apply Develop Review Opportunity Detail [/develop/reviewOpportunities/{challengeId}/apply]
### Apply Develop Review Opportunity Information [POST]

+ Request

Authorization : Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZHwxMzI0NTYiLCJleHAiOjEzOTQwODA3MTEsImF1ZCI6InRvcGNvZGVyIiwiaWF0IjoxMzk0MDIwNzExfQ.xaaaElykyAq3woRRkcFQSUK0gvKnRCOhCD57x070GJ4

+ Parameters

+ challengeId (required, number, `30000000`) ... The challenge id.
+ reviewApplicationRoleId (optional, number, `1`) ... The review application role id to apply.

+ Response 200 (application/json)

{
"message": "Your review application for this contest has been cancelled."
}

+ Response 200 (application/json)

{
"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."
}

+ Response 200 (application/json)

{
"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."
}

+ Response 400 (application/json)

{
"name":"Bad Request",
"value":"400",
"description":"challengeId should be number."
}

+ Response 400 (application/json)

{
"name":"Bad Request",
"value":"400",
"description":"challengeId should be positive."
}

+ Response 400 (application/json)

{
"name":"Bad Request",
"value":"400",
"description":"challengeId should be Integer."
}

+ Response 400 (application/json)

{
"name":"Bad Request",
"value":"400",
"description":"challengeId should be less or equal to 2147483647."
}

+ Response 400 (application/json)

{
"name":"Bad Request",
"value":"400",
"description":"reviewApplicationRoleId should be an element of 1,2,3,4,5,6,7,8,9."
}

+ Response 400 (application/json)

{
"name":"Bad Request",
"value":"400",
"description":"The challenge is not existed or don't have any review opportunities or review registration is not open."
}

+ Response 400 (application/json)

{
"name":"Bad Request",
"value":"400",
"description":"You can't apply the review application role that do not belong to this challenge."
}

+ Response 403 (application/json)

{
"name":"Forbidden",
"value":"403",
"description":"You are not a Review Board member."
}

+ Response 400 (application/json)

{
"name":"Bad Request",
"value":"400",
"description":"You are already assigned as reviewer for the contest."
}

+ Response 400 (application/json)

{
"name":"Bad Request",
"value":"400",
"description":"There are no open positions for this challenge."
}

+ Response 400 (application/json)

{
"name":"Bad Request",
"value":"400",
"description":"There is no open positions for selected review application role: Primary Reviewer."
}

+ Response 403 (application/json)

{
"name":"Forbidden",
"value":"403",
"description":"You should agree with all terms of use."
}

+ Response 401 (application/json)

{
"name":"Unauthorized",
"value":"401",
"description":"Anonymous user don't have permission to access this api."
}

+ Response 403 (application/json)

{
"name":"Forbidden",
"value":"403",
"description":"The user is not allowed to register this challenge review."
}

+ Response 500 (application/json)

{
"name":"Internal Server Error",
"value":"500",
"description":"Unknown server error. Please contact support."
}

+ Response 503 (application/json)

{
"name":"Service Unavailable",
"value":"503",
"description":"Servers are up but overloaded. Try again later."
}


## Challenge Reviewers Collection [/develop/reviewers/{contestType}]
### List reviewers of current challenge type [GET]
Expand Down
12 changes: 8 additions & 4 deletions initializers/challengeHelper.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/*
* Copyright (C) 2013 - 2014 TopCoder Inc., All Rights Reserved.
*
* @version 1.1
* @author ecnu_haozi, bugbuka
* @version 1.2
* @author ecnu_haozi, bugbuka, Ghost_141
* Refactor common code out from challenge.js.
*
* changes in 1.1:
* add common function getForumWrapper, aduitResourceAddition
* Changes in 1.2:
* - Add new parameter in getChallengeTerms.
*/
"use strict";

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

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

if (!rows[0].reg_open) {
// Update check to use flag.
if (requireRegOpen && !rows[0].reg_open) {
cb(new ForbiddenError('Registration Phase of this challenge is not open.'));
return;
}
Expand Down
17 changes: 16 additions & 1 deletion initializers/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* This module contains helper functions.
* @author Sky_, Ghost_141, muzehyun, kurtrips, isv, LazyChild, hesibo
* @version 1.21
* @version 1.22
* changes in 1.1:
* - add mapProperties
* changes in 1.2:
Expand Down Expand Up @@ -60,6 +60,8 @@
* - added activation code generation function (copied from memberRegistration.js)
* Changes in 1.21:
* - add LIST_TYPE_REGISTRATION_STATUS_MAP and VALID_LIST_TYPE.
* Changes in 1.22:
* - add allTermsAgreed method.
*/
"use strict";

Expand Down Expand Up @@ -1195,6 +1197,19 @@ helper.checkUserExists = function (handle, api, dbConnectionMap, callback) {
});
};

/**
* check if the every terms has been agreed
*
* @param {Array} terms - The terms.
* @returns {Boolean} true if all terms agreed otherwise false.
* @since 1.16
*/
helper.allTermsAgreed = function (terms) {
return _.every(terms, function (term) {
return term.agreed;
});
};

/**
* Gets all file types and caches them.
* @param {Object} api - the action hero api object
Expand Down
6 changes: 6 additions & 0 deletions queries/check_reviewer
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT 1
FROM rboard_user ru
INNER JOIN project p ON ru.project_type_id = p.project_category_id
WHERE ru.user_id = @user_id@
AND ru.status_id = 100
AND p.project_id = @challenge_id@
5 changes: 5 additions & 0 deletions queries/check_reviewer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name" : "check_reviewer",
"db" : "tcs_catalog",
"sqlfile" : "check_reviewer"
}
11 changes: 11 additions & 0 deletions queries/get_assigned_review_resource_role
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SELECT
DISTINCT
r.resource_role_id
, u.user_id
FROM resource r
INNER JOIN resource_info ri ON r.resource_id = ri.resource_id AND ri.resource_info_type_id = 1
INNER JOIN user u ON u.user_id = ri.value
INNER JOIN review_auction ra ON ra.project_id = r.project_id
INNER JOIN review_application_role_lu rarl ON rarl.review_auction_type_id = ra.review_auction_type_id
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
WHERE r.project_id = @challenge_id@
5 changes: 5 additions & 0 deletions queries/get_assigned_review_resource_role.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name" : "get_assigned_review_resource_role",
"db" : "tcs_catalog",
"sqlfile" : "get_assigned_review_resource_role"
}
1 change: 1 addition & 0 deletions queries/get_next_sequence_tcs_catalog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select SEQUENCE_@seq_name@.NEXTVAL as next_id from table(set{1})
5 changes: 5 additions & 0 deletions queries/get_next_sequence_tcs_catalog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name" : "get_next_sequence_tcs_catalog",
"db" : "tcs_catalog",
"sqlfile" : "get_next_sequence_tcs_catalog"
}
12 changes: 12 additions & 0 deletions queries/get_user_review_applications
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SELECT
rarl.name AS role
, rarl.review_application_role_id AS role_id
, ra.review_application_id
, rasl.name AS status
FROM review_application ra
INNER JOIN user u ON u.user_id = ra.user_id
INNER JOIN review_auction rauc ON rauc.review_auction_id = ra.review_auction_id AND rauc.project_id = @challenge_id@
INNER JOIN review_application_role_lu rarl ON rarl.review_application_role_id = ra.review_application_role_id
INNER JOIN review_application_status_lu rasl ON rasl.review_application_status_id = ra.review_application_status_id
WHERE u.user_id = @user_id@
ORDER BY ra.create_date ASC
5 changes: 5 additions & 0 deletions queries/get_user_review_applications.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name" : "get_user_review_applications",
"db" : "tcs_catalog",
"sqlfile" : "get_user_review_applications"
}
2 changes: 1 addition & 1 deletion queries/insert_resource
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
INSERT INTO resource
( resource_id,
( resource_id,
resource_role_id,
project_id,
user_id,
Expand Down
2 changes: 2 additions & 0 deletions queries/insert_review_application
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO review_application(review_application_id, user_id, review_auction_id, review_application_role_id, review_application_status_id, create_date, modify_date)
VALUES(@review_application_id@, @user_id@, @review_auction_id@, @role_id@, @status@, current, current)
5 changes: 5 additions & 0 deletions queries/insert_review_application.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name" : "insert_review_application",
"db" : "tcs_catalog",
"sqlfile" : "insert_review_application"
}
Loading