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

Challenges api improvement #186

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
2cd2a41
Module Assembly - TopCoder NodeJS Challenges RSS Output API
Ghost141 Mar 20, 2014
19a7947
revert
Ghost141 Apr 2, 2014
dd1524d
Merge pull request #168 from Ghost141/challenges_api_fix
wenhui-wd Apr 2, 2014
a391cbd
submission size set to 10M.
mashannon168 Apr 2, 2014
b4f4277
Update User Settings API
wenhui-wd Apr 2, 2014
ed17ec1
update user settings api
wenhui-wd Apr 2, 2014
ef7e6bc
update user setting api
wenhui-wd Apr 2, 2014
c016a85
Update user settings api
wenhui-wd Apr 2, 2014
f8c293e
Update User Settings API
wenhui-wd Apr 2, 2014
ffe82a6
update to use <upload_id>_<file name> to store to upload.parameter.
mashannon168 Apr 2, 2014
5c02186
docusign callback local commit
Apr 3, 2014
ff4411e
merged docusign.js by hand
Apr 3, 2014
9075793
docusign callback merged by hand
Apr 3, 2014
2322b93
Merge User Settings API to My Profile API
wenhui-wd Apr 3, 2014
3ed9119
Payments API
wenhui-wd Apr 3, 2014
f96456d
fix typo
wenhui-wd Apr 3, 2014
7684939
Fix for timezone.
renyu-io Apr 3, 2014
0be6bba
Merge pull request #169 from LazyChild/timezone_fix
wenhui-wd Apr 3, 2014
8a127d9
support optional param for user profile API with granular data retrie…
Apr 3, 2014
3854454
support optional param for user profile API with granular data retrie…
Apr 3, 2014
cc0c939
Merge branch 'james-users-opt' of github.com:cloudspokes/tc-api into …
Apr 3, 2014
9dc88c5
Merge branch 'james-users-opt' into james-users-api-data
Apr 3, 2014
d797f1b
allow timeout to be set via env var
Apr 3, 2014
0a6679a
Merge pull request #170 from cloudspokes/james-users-api-data
mashannon168 Apr 3, 2014
8cc9781
Add optional tracking parameter
Apr 3, 2014
2217fe7
Merge branch 'member_registration_api_update_2'
Apr 3, 2014
3af6d99
update API doc for Member Registration API
Apr 3, 2014
4f25f08
revert back to base64 approach for submit dev challenge submission API
Apr 4, 2014
6753740
Get Marathon Match Challenge Reg Info API
hesibo Apr 4, 2014
f269186
Merge pull request #171 from hesibo/master
skyhit Apr 4, 2014
7e72833
Merge pull request #172 from cloudspokes/timezone-fix
wenhui-wd Apr 4, 2014
e66a282
1. Merged docusign callback and recipient view url.
Apr 4, 2014
c046dff
Merged docusign parts with latest
Apr 4, 2014
a52843f
Add Payment Summary Info
wenhui-wd Apr 4, 2014
b8c157e
Add new sort columns for search challenge API.
renyu-io Apr 4, 2014
254ba78
Add sort columns.
renyu-io Apr 4, 2014
5a87501
Challenge API update.
renyu-io Apr 4, 2014
ad860ba
Merge pull request #174 from LazyChild/add_search_columns
wenhui-wd Apr 4, 2014
5c1d547
Merge challenge detail api.
renyu-io Apr 3, 2014
854c414
round the digital run points to 1 decimal digits.
renyu-io Apr 4, 2014
24a03f6
Merge
Ghost141 Apr 4, 2014
4f7005c
Merge pull request #175 from LazyChild/merge_challenge_api
wenhui-wd Apr 4, 2014
a5c0aba
merge
Ghost141 Apr 4, 2014
4065632
Merge pull request #176 from Ghost141/challenges_rss
wenhui-wd Apr 4, 2014
66a9a65
change the parameter name.
renyu-io Apr 4, 2014
5fb6fef
change the parameter name.
renyu-io Apr 4, 2014
709a401
Merge remote-tracking branch 'origin/merge_challenge_api' into merge_…
renyu-io Apr 4, 2014
8e710e1
Merge pull request #177 from LazyChild/merge_challenge_api
wenhui-wd Apr 4, 2014
917dd57
Fixed code error.
mashannon168 Apr 4, 2014
0050b61
Revert "Fixed code error."
mashannon168 Apr 4, 2014
d3cedf1
Fix undefined error in challenges.js
Ghost141 Apr 4, 2014
1a93441
Merge pull request #178 from Ghost141/challenges_rss
wenhui-wd Apr 4, 2014
8a17b7b
Get docusign envelop query needs to check is_completed = 1
mashannon168 Apr 4, 2014
4e1a827
Generate Reset Token
isvisv Apr 5, 2014
6f045a7
Rename all "contestId" in actions/challenges.js to "challengeId"
Ghost141 Apr 5, 2014
fa47e5a
Update Get Studio Challenge Detail API definition.
Ghost141 Apr 5, 2014
775c144
Merge pull request #180 from Ghost141/challenges_rss
wenhui-wd Apr 5, 2014
21d4a9d
adding docusgn to latest code
Apr 7, 2014
fc155e5
Merge pull request #179 from isvisv/master
wenhui-wd Apr 7, 2014
3f9adef
removed 2 docusign recipient view url tests
Apr 7, 2014
adb0b62
yet another merge of updated tc-api
Apr 7, 2014
49179c9
merger docusign with latest code
Apr 7, 2014
e53b3b7
Merge pull request #173 from GeezerButler/master
skyhit Apr 8, 2014
e60992f
Module Assembly - TopCoder NodeJS Unregister Challenge API
bugbuka Apr 8, 2014
3e535dd
Merge pull request #181 from bugbuka/master
skyhit Apr 8, 2014
fd08d91
Module Assembly - TopCoder NodeJS Apply Develop Review Opportunity API
Ghost141 Mar 21, 2014
89e9f97
merge
Ghost141 Apr 8, 2014
b826873
Merge pull request #182 from Ghost141/apply_review
skyhit Apr 9, 2014
2577570
Improve develop review opportunity detail api.
Ghost141 Apr 9, 2014
6bd3f9e
Merge pull request #183 from Ghost141/apply_review
skyhit Apr 9, 2014
c4f81a7
performance fix for challenges api.
Ghost141 Apr 9, 2014
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
79 changes: 22 additions & 57 deletions actions/challengeRegistration.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
*
* The APIs to register a challenge (studio category or software category) for the current logged-in user.
*
* @version 1.2
* @author ecnu_haozi, xjtufreeman, TCSASSEMBLER
* @version 1.3
* @author ecnu_haozi, xjtufreeman, bugbuka
*
* changes in 1.1:
* Combine Challenge Registration API(BUGR-11058)
*
* changes in 1.2:
* Integrate the forums operation(Module Assembly - Integrating Forums Wrapper with Challenge Registration API)
*
* changes in 1.3:
* move common function getForumWrapper, aduitResourceAddition to challengeHelper.js
*/
"use strict";

Expand All @@ -26,25 +29,6 @@ var ForbiddenError = require('../errors/ForbiddenError');
*/
var forumWrapper = null;

/**
* Get forum wrapper. It is initialized only once.
* @param {Object} api The api object that is used to access the infrastructure.
* @param {Function<err, forumWrapper>} callback the callback function
*/
var getForumWrapper = function (api, callback) {
if (forumWrapper) {
callback(null, forumWrapper);
} else {
try {
forumWrapper = new ForumWrapper(api.config.general.devForumJNDI);
callback(null, forumWrapper);
} catch (ex) {
api.log('Failed to connect to forum: ' + ex + " " + (ex.stack || ''), 'error');
callback(new Error('Failed to connect to forum'));
}
}
};

//constants
var DESIGN_PROJECT_TYPE = 1,
DEVELOPMENT_PROJECT_TYPE = 2,
Expand Down Expand Up @@ -162,27 +146,6 @@ var persistResource = function (api, resourceId, userId, challengeId, dbConnecti
});
};

/**
* Audit the challenge registration on table 'tcs_catalog.project_user_audit'.
*
* @param {Object} api The api object that is used to access the infrastructure.
* @param {Number} userId The current logged-in user's id.
* @param {Number} challengeId The id of the challenge to register.
* @param {Object} dbConnectionMap The database connection map for the current request.
* @param {Function<err, data>} next The callback to be called after this function is done.
*/
var aduitResourceAddition = function (api, userId, challengeId, dbConnectionMap, next) {
api.dataAccess.executeQuery("audit_challenge_registration", {
projectId: challengeId,
resourceUserId: userId,
resourceRoleId: SUBMITTER_RESOURCE_ROLE_ID,
auditActionTypeId: PROJECT_USER_AUDIT_CREATE_TYPE,
actionUserId: userId
},
dbConnectionMap,
next);
};

/**
* Check if the rating suit for software category contests.
* The code logic is duplicated from server-side java code.
Expand Down Expand Up @@ -282,7 +245,7 @@ var projectTrack = function (api, userId, challengeId, componentInfo, dbConnecti
function (resourceId, callback) {
async.parallel([
function (cb) {
aduitResourceAddition(api, userId, challengeId, dbConnectionMap, cb);
api.challengeHelper.aduitResourceAddition(api, userId, challengeId, SUBMITTER_RESOURCE_ROLE_ID, PROJECT_USER_AUDIT_CREATE_TYPE, dbConnectionMap, cb);
},
function (cb) {
prepareProjectResult(
Expand Down Expand Up @@ -487,7 +450,7 @@ var grantForumAccess = function (api, userId, activeForumCategoryId, next) {
api.log('start to grant user ' + userId + ' forum category ' + activeForumCategoryId + ' access.');
async.waterfall([
function (cb) {
getForumWrapper(api, cb);
api.challengeHelper.getForumWrapper(api, cb);
}, function (forumWrapper, cb) {
forumWrapper.assignRole(userId, "Software_Users_" + activeForumCategoryId, function (err) {
if (err) {
Expand Down Expand Up @@ -646,8 +609,8 @@ var timelineNotification = function (api, userId, challengeId, dbConnectionMap,
dbConnectionMap,
cb);
} else {
cb(null);
}
cb(null);
}
}
], next);
};
Expand Down Expand Up @@ -685,23 +648,23 @@ var registerSoftwareChallengeAction = function (api, connection, next) {
if (connection.dbConnectionMap) {
api.log("Execute registerSoftwareChallengeAction#run", 'debug');

var challengeId = Number(connection.params.challengeId);
var sqlParams = {
challengeId: challengeId,
user_id: connection.caller.userId
};
var execQuery = function (name) {
return function (cbx) {
api.dataAccess.executeQuery(name, sqlParams, connection.dbConnectionMap, cbx);
var challengeId = Number(connection.params.challengeId),
sqlParams = {
challengeId: challengeId,
user_id: connection.caller.userId
},
execQuery = function (name) {
return function (cbx) {
api.dataAccess.executeQuery(name, sqlParams, connection.dbConnectionMap, cbx);
};
};
};
async.waterfall([
function(cb) {
function (cb) {
async.parallel({
isCopilotPosting: execQuery('check_challenge_is_copilot_posting'),
isCopilot: execQuery('check_is_copilot')
}, cb);
}, function(res, cb) {
}, function (res, cb) {
if (res.isCopilotPosting.length > 0 && res.isCopilotPosting[0].challenge_is_copilot) {
if (res.isCopilot.length === 0 || !res.isCopilot[0].user_is_copilot) {
cb(new ForbiddenError('You should be a copilot before register a copilot posting.'));
Expand All @@ -713,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 @@ -763,6 +727,7 @@ var registerStudioChallengeAction = function (api, connection, next) {
connection,
challengeId,
"Submitter",
true,
connection.dbConnectionMap,
cb
);
Expand Down
Loading