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

Commit 4065632

Browse files
committed
Merge pull request #176 from Ghost141/challenges_rss
Challenges rss
2 parents 4f7005c + a5c0aba commit 4065632

31 files changed

+2609
-100
lines changed

actions/challengeRegistration.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,8 @@ var timelineNotification = function (api, userId, challengeId, dbConnectionMap,
646646
dbConnectionMap,
647647
cb);
648648
} else {
649-
cb(null);
650-
}
649+
cb(null);
650+
}
651651
}
652652
], next);
653653
};
@@ -685,23 +685,23 @@ var registerSoftwareChallengeAction = function (api, connection, next) {
685685
if (connection.dbConnectionMap) {
686686
api.log("Execute registerSoftwareChallengeAction#run", 'debug');
687687

688-
var challengeId = Number(connection.params.challengeId);
689-
var sqlParams = {
690-
challengeId: challengeId,
691-
user_id: connection.caller.userId
692-
};
693-
var execQuery = function (name) {
694-
return function (cbx) {
695-
api.dataAccess.executeQuery(name, sqlParams, connection.dbConnectionMap, cbx);
688+
var challengeId = Number(connection.params.challengeId),
689+
sqlParams = {
690+
challengeId: challengeId,
691+
user_id: connection.caller.userId
692+
},
693+
execQuery = function (name) {
694+
return function (cbx) {
695+
api.dataAccess.executeQuery(name, sqlParams, connection.dbConnectionMap, cbx);
696+
};
696697
};
697-
};
698698
async.waterfall([
699-
function(cb) {
699+
function (cb) {
700700
async.parallel({
701701
isCopilotPosting: execQuery('check_challenge_is_copilot_posting'),
702702
isCopilot: execQuery('check_is_copilot')
703703
}, cb);
704-
}, function(res, cb) {
704+
}, function (res, cb) {
705705
if (res.isCopilotPosting.length > 0 && res.isCopilotPosting[0].challenge_is_copilot) {
706706
if (res.isCopilot.length === 0 || !res.isCopilot[0].user_is_copilot) {
707707
cb(new ForbiddenError('You should be a copilot before register a copilot posting.'));

actions/challenges.js

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,6 @@ var ALLOWABLE_SORT_COLUMN = [
9898
"postingDate", "numSubmissions", "numRegistrants", "currentPhaseRemainingTime", "currentPhaseName", "registrationOpen"
9999
];
100100

101-
/**
102-
* Represents a ListType enum
103-
*/
104-
var ListType = { ACTIVE: "ACTIVE", OPEN: "OPEN", UPCOMING: "UPCOMING", PAST: "PAST" };
105-
106-
/**
107-
* Represents a predefined list of valid list type.
108-
*/
109-
var ALLOWABLE_LIST_TYPE = [ListType.ACTIVE, ListType.OPEN, ListType.UPCOMING, ListType.PAST];
110-
111101
/**
112102
* Represents Percentage of Placement Points for digital run
113103
*/
@@ -118,24 +108,6 @@ var DR_POINT = [[1], [0.7, 0.3], [0.65, 0.25, 0.10], [0.6, 0.22, 0.1, 0.08], [0.
118108
*/
119109
var MAX_INT = 2147483647;
120110

121-
/**
122-
* The list type and registration phase status map.
123-
*/
124-
var LIST_TYPE_REGISTRATION_STATUS_MAP = {};
125-
LIST_TYPE_REGISTRATION_STATUS_MAP[ListType.ACTIVE] = [2, 3];
126-
LIST_TYPE_REGISTRATION_STATUS_MAP[ListType.OPEN] = [2];
127-
LIST_TYPE_REGISTRATION_STATUS_MAP[ListType.UPCOMING] = [1];
128-
LIST_TYPE_REGISTRATION_STATUS_MAP[ListType.PAST] = [3];
129-
130-
/**
131-
* The list type and project status map.
132-
*/
133-
var LIST_TYPE_PROJECT_STATUS_MAP = {};
134-
LIST_TYPE_PROJECT_STATUS_MAP[ListType.ACTIVE] = [1];
135-
LIST_TYPE_PROJECT_STATUS_MAP[ListType.OPEN] = [1];
136-
LIST_TYPE_PROJECT_STATUS_MAP[ListType.UPCOMING] = [2];
137-
LIST_TYPE_PROJECT_STATUS_MAP[ListType.PAST] = [4, 5, 6, 7, 8, 9, 10, 11];
138-
139111
/**
140112
* This copilot posting project type id
141113
*/
@@ -207,7 +179,7 @@ function validateInputParameter(helper, caller, challengeType, query, filter, pa
207179
helper.checkPositiveInteger(pageSize, "pageSize") ||
208180
helper.checkMaxNumber(pageSize, MAX_INT, 'pageSize') ||
209181
helper.checkMaxNumber(pageIndex, MAX_INT, 'pageIndex') ||
210-
helper.checkContains(ALLOWABLE_LIST_TYPE, type.toUpperCase(), "type") ||
182+
helper.checkContains(helper.ALLOWABLE_LIST_TYPE, type.toUpperCase(), "type") ||
211183
checkQueryParameterAndSortColumn(helper, type, query, sortColumn);
212184

213185
if (_.isDefined(query.communityId)) {
@@ -480,7 +452,7 @@ var searchChallenges = function (api, connection, dbConnectionMap, community, ne
480452

481453
sortOrder = query.sortorder || "asc";
482454
sortColumn = query.sortcolumn || DEFAULT_SORT_COLUMN;
483-
listType = (query.listtype || ListType.OPEN).toUpperCase();
455+
listType = (query.listtype || helper.ListType.OPEN).toUpperCase();
484456
pageIndex = Number(query.pageindex || 1);
485457
pageSize = Number(query.pagesize || 50);
486458

@@ -508,8 +480,8 @@ var searchChallenges = function (api, connection, dbConnectionMap, community, ne
508480
// Set the project type id
509481
sqlParams.project_type_id = challengeType.category;
510482
// Set the submission phase status id.
511-
sqlParams.registration_phase_status = LIST_TYPE_REGISTRATION_STATUS_MAP[listType];
512-
sqlParams.project_status_id = LIST_TYPE_PROJECT_STATUS_MAP[listType];
483+
sqlParams.registration_phase_status = helper.LIST_TYPE_REGISTRATION_STATUS_MAP[listType];
484+
sqlParams.project_status_id = helper.LIST_TYPE_PROJECT_STATUS_MAP[listType];
513485
sqlParams.userId = caller.userId || 0;
514486

515487
// Check the private challenge access
@@ -788,7 +760,7 @@ var getChallenge = function (api, connection, dbConnectionMap, isStudio, next) {
788760
submissionEndDate : formatDate(data.submission_end_date)
789761
};
790762

791-
if (connection.action == "getChallenge") {
763+
if (connection.action === "getChallenge") {
792764
challenge.type = isStudio ? 'design' : 'develop';
793765
}
794766

@@ -1023,7 +995,7 @@ var submitForDevelopChallenge = function (api, connection, dbConnectionMap, next
1023995
console.log('-------------------------------------------');
1024996
console.log(stats.size + '\t' + api.config.submissionMaxSizeBytes);
1025997
console.log('-------------------------------------------');
1026-
998+
1027999
if (stats.size > api.config.submissionMaxSizeBytes) {
10281000
cb(new RequestTooLargeError(
10291001
"The submission file size is greater than the max allowed size: " + (api.config.submissionMaxSizeBytes / 1024) + " KB."
@@ -1049,7 +1021,7 @@ var submitForDevelopChallenge = function (api, connection, dbConnectionMap, next
10491021
fileName: uploadId + "_" + fileName
10501022
});
10511023
api.dataAccess.executeQuery("insert_upload", sqlParams, dbConnectionMap, cb);
1052-
}, function(notUsed, cb) {
1024+
}, function (notUsed, cb) {
10531025
//Now check if the contest is a CloudSpokes one and if it needs to submit the thurgood job
10541026
if (!_.isUndefined(thurgoodPlatform) && !_.isUndefined(thurgoodLanguage) && type === 'final') {
10551027
//Make request to the thurgood job api url
@@ -1541,11 +1513,11 @@ exports.getChallenge = {
15411513
run: function (api, connection, next) {
15421514
if (connection.dbConnectionMap) {
15431515
api.log("Execute getChallenge#run", 'debug');
1544-
api.dataAccess.executeQuery('check_challenge_exists', {challengeId: connection.params.contestId}, connection.dbConnectionMap, function(err, result) {
1516+
api.dataAccess.executeQuery('check_challenge_exists', {challengeId: connection.params.contestId}, connection.dbConnectionMap, function (err, result) {
15451517
if (err) {
15461518
api.helper.handleError(api, connection, err);
15471519
next(connection, true);
1548-
} else if (result.length == 0) {
1520+
} else if (result.length === 0) {
15491521
api.helper.handleError(api, connection, new NotFoundError("Challenge not found."));
15501522
next(connection, true);
15511523
} else {
@@ -1771,7 +1743,7 @@ var DEFAULT_FONT_URL = 'community.topcoder.com/studio/the-process/font-policy/';
17711743
* Gets the file type based on the file name extension. Return null if not found.
17721744
* @since 1.14
17731745
*
1774-
* @param {Object} file - The file name
1746+
* @param {Object} fileName - The file name
17751747
* @param {Object} fileTypes - The file types from which to read
17761748
*/
17771749
var getFileType = function (fileName, fileTypes) {

actions/docusign.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ exports.action = {
7474
api.log("Executing getDocusignViewURL#run", 'debug');
7575
async.waterfall([
7676
function (cb) {
77-
var x, spl, u;
77+
var x, spl;
7878

7979
//Check if the templateId is valid
8080
if (!templateId.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i)) {
@@ -185,8 +185,8 @@ exports.action = {
185185
//persist the new envelope to database
186186
sqlParams.envelopeId = resp.envelopeId;
187187
sqlParams.complete = 0;
188-
api.dataAccess.executeQuery(
189-
'insert_docusign_envelope', sqlParams, dbConnectionMap, function (err) {
188+
api.dataAccess.executeQuery('insert_docusign_envelope', sqlParams, dbConnectionMap,
189+
function (err) {
190190
if (err) {
191191
cb(err);
192192
return;

actions/download.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ var downloadDesignSubmission = function (api, connection, dbConnectionMap, next)
573573
noRights = false;
574574
}
575575

576-
//Screener can download submission if screening has started
576+
//Screener can download submission if screening has started
577577
if (_.intersection(myResourceRoleIds, screenerRoles).length > 0 && basicInfo[0].is_at_or_after_screening) {
578578
noRights = false;
579579
}
@@ -595,9 +595,9 @@ var downloadDesignSubmission = function (api, connection, dbConnectionMap, next)
595595
}
596596
}
597597

598-
//managers can download the submissions anytime
598+
//managers can download the submissions anytime
599599
if (noRights && isManager) {
600-
noRights = false;
600+
noRights = false;
601601
}
602602

603603
//everyone - can download previews and watermarks after review and if submissions are viewable

actions/memberStatistics.js

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,24 +118,26 @@ function getBasicUserProfile(api, handle, privateInfoEligibility, dbConnectionMa
118118
sqlParams = {
119119
handle: handle
120120
},
121-
result;
121+
result,
122+
loadData,
123+
requestedData,
124+
parts;
122125

123-
var loadData;
124126
// check for an optional data query string param than enables loading a subset of data
125-
var requestedData = connection.rawConnection.parsedURL.query.data;
127+
requestedData = connection.rawConnection.parsedURL.query.data;
126128
if (_.isDefined(requestedData)) {
127129
// NOTE: an empty value is acceptable and indicates only basic data is returned
128130
loadData = {};
129131
if (requestedData) {
130132
// data is comma delimited string of requested data
131-
var parts = requestedData.split(',');
133+
parts = requestedData.split(',');
132134
_.each(parts, function (part) {
133135
loadData[part] = true;
134136
});
135137
}
136138
api.log("Requested data param found: " + requestedData, "debug");
137139
} else {
138-
loadData = {earnings:true, ratings:true, achievements:true, address:true, email:true}; // load all data by default
140+
loadData = {earnings: true, ratings: true, achievements: true, address: true, email: true}; // load all data by default
139141
}
140142

141143
async.waterfall([
@@ -159,14 +161,20 @@ function getBasicUserProfile(api, handle, privateInfoEligibility, dbConnectionMa
159161
};
160162
async.parallel({
161163
basic: execQuery('basic'),
162-
earning: loadData.earnings ? execQuery('overall_earning') : function(cbx) { cbx(); },
163-
ratingSummary: loadData.ratings ? execQuery('rating_summary') : function(cbx) { cbx(); },
164-
achievements: loadData.achievements ? execQuery('achievements') : function(cbx) { cbx(); },
164+
earning: loadData.earnings ? execQuery('overall_earning') : function (cbx) { cbx(); },
165+
ratingSummary: loadData.ratings ? execQuery('rating_summary') : function (cbx) { cbx(); },
166+
achievements: loadData.achievements ? execQuery('achievements') : function (cbx) { cbx(); },
165167
privateInfo: loadData.address && privateInfoEligibility ? execQuery('private') : function (cbx) { cbx(); },
166168
emails: loadData.email && privateInfoEligibility ? execQuery('private_email') : function (cbx) { cbx(); }
167169
}, cb);
168170
}, function (results, cb) {
169-
var basic = results.basic[0];
171+
var basic = results.basic[0],
172+
ratingSummary,
173+
achievements,
174+
emails,
175+
appendIfNotEmpty,
176+
privateInfo,
177+
address;
170178

171179
result = {
172180
handle: basic.handle,
@@ -181,7 +189,7 @@ function getBasicUserProfile(api, handle, privateInfoEligibility, dbConnectionMa
181189
}
182190

183191
if (loadData.ratings) {
184-
var ratingSummary = [];
192+
ratingSummary = [];
185193
results.ratingSummary.forEach(function (item) {
186194
ratingSummary.push({
187195
name: helper.getPhaseName(item.phase_id),
@@ -193,7 +201,7 @@ function getBasicUserProfile(api, handle, privateInfoEligibility, dbConnectionMa
193201
}
194202

195203
if (loadData.achievements) {
196-
var achievements = [];
204+
achievements = [];
197205
results.achievements.forEach(function (item) {
198206
achievements.push({
199207
date: item.achievement_date,
@@ -205,7 +213,7 @@ function getBasicUserProfile(api, handle, privateInfoEligibility, dbConnectionMa
205213
}
206214

207215
if (privateInfoEligibility && loadData.email) {
208-
var emails = [];
216+
emails = [];
209217
results.emails.forEach(function (item) {
210218
emails.push({
211219
email: item.email,
@@ -217,22 +225,22 @@ function getBasicUserProfile(api, handle, privateInfoEligibility, dbConnectionMa
217225
}
218226

219227
if (privateInfoEligibility && loadData.address && results.privateInfo && results.privateInfo[0]) {
220-
var appendIfNotEmpty = function (str) {
228+
appendIfNotEmpty = function (str) {
221229
var ret = '';
222230
if (str && str.length > 0) {
223231
ret += ', ' + str;
224232
}
225233
return ret;
226234
};
227235

228-
var privateInfo = results.privateInfo[0];
236+
privateInfo = results.privateInfo[0];
229237

230238
result.name = privateInfo.first_name + ' ' + privateInfo.last_name;
231239
result.age = privateInfo.age;
232240
result.gender = privateInfo.gender;
233241
result.shirtSize = privateInfo.shirt_size;
234242

235-
var address = privateInfo.address1;
243+
address = privateInfo.address1;
236244
// if address1 is undefined, there is no address.
237245
if (address) {
238246
address += appendIfNotEmpty(privateInfo.address2);

0 commit comments

Comments
 (0)