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

Commit af5f946

Browse files
committed
Merge pull request #435 from appirio-tech/qa
Release
2 parents d4cb587 + b96d21d commit af5f946

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

actions/challengeRegistration.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -869,9 +869,12 @@ exports.registerChallenge = {
869869
if (error) {
870870
console.log("error: " + error);
871871
cb(error);
872-
} else {
873-
console.log("error11: " + error);
874-
api.dataAccess.executeQuery('check_challenge_exists', {challengeId: challengeId}, connection.dbConnectionMap, cb);
872+
} else {
873+
api.helper.checkUserActivated(connection.caller.handle, api, connection.dbConnectionMap, function (err, inactive) {
874+
var fail = err || inactive;
875+
if (fail) cb(fail);
876+
else api.dataAccess.executeQuery('check_challenge_exists', {challengeId: challengeId}, connection.dbConnectionMap, cb);
877+
}, "You must activate your account in order to participate. Please check your e-mail in order to complete the activation process, or contact [email protected] if you did not receive an e-mail.");
875878
}
876879
}, function (result, cb) {
877880
if (result.length > 0) {

actions/challenges.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ var QUERY_PATH = './queries/';
125125
*/
126126
var TECHNOLOGY_FILTER = ' AND EXISTS (SELECT DISTINCT 1 FROM comp_technology ct WHERE ct.comp_vers_id = pi1.value ' +
127127
'AND ct.technology_type_id IN (@filter@))';
128-
128+
129+
var EXT_TECHNOLOGY_FILTER = ' AND (pn.value LIKE ("%@tech@%") OR EXISTS (SELECT DISTINCT 1 FROM comp_technology ct WHERE ct.comp_vers_id = pi1.value ' +
130+
'AND ct.technology_type_id IN (@filter@)))';
129131
/**
130132
* The platform filter for challenges api.
131133
* @since 1.23
@@ -745,14 +747,15 @@ function transferResultV2(src, helper) {
745747
* @param {String} content - the content that need in template.
746748
* @since 1.23
747749
*/
748-
var editSql = function (sql, template, content) {
750+
var editSql = function (sql, template, content, tech) {
749751
// For empty sql just return it.
750752
if (sql.length === 0) {
751753
return sql;
752754
}
753755
var index = sql.toLowerCase().indexOf('order by');
754756
if (!_.isUndefined(template)) {
755757
template = template.replace('@filter@', content);
758+
template = template.replace('@tech@', tech);
756759
}
757760
return sql.slice(0, index) + template + sql.slice(index, sql.length);
758761
};
@@ -776,8 +779,13 @@ var addFilter = function (sql, filter, isMyChallenges, helper, caller) {
776779

777780
if (_.isDefined(filter.technologies)) {
778781
technology = filter.technologies.join(', ');
779-
sql.count = editSql(sql.count, TECHNOLOGY_FILTER, technology);
780-
sql.data = editSql(sql.data, TECHNOLOGY_FILTER, technology);
782+
if (filter.tech) {
783+
sql.count = editSql(sql.count, EXT_TECHNOLOGY_FILTER, technology, filter.tech);
784+
sql.data = editSql(sql.data, EXT_TECHNOLOGY_FILTER, technology, filter.tech);
785+
} else {
786+
sql.count = editSql(sql.count, TECHNOLOGY_FILTER, technology);
787+
sql.data = editSql(sql.data, TECHNOLOGY_FILTER, technology);
788+
}
781789
}
782790

783791
if (_.isDefined(filter.challengeType)) {
@@ -3708,6 +3716,10 @@ var getChallenges = function (api, connection, listType, isMyChallenges, next) {
37083716
},
37093717
function (cb) {
37103718
validateInputParameterV2(helper, caller, type, query, filter, pageIndex, pageSize, sortColumn, sortOrder, listType, dbConnectionMap, cb);
3719+
3720+
if (filter.technologies) {
3721+
filter.tech = filter.technologies.split(',')[0];
3722+
}
37113723
}, function (cb) {
37123724
if (pageIndex === -1) {
37133725
pageIndex = 1;

apiary.apib

+1-1
Original file line numberDiff line numberDiff line change
@@ -9946,7 +9946,7 @@ Request
99469946
}
99479947

99489948
## Register for a software/studio challenge [/challenges/{challengeId}/register]
9949-
### Register for a software/studio challenge [GET]
9949+
### Register for a software/studio challenge [POST]
99509950

99519951
+ Parameters
99529952
+ challengeId (required, number, `1234567`) ... The challenge for which to register

initializers/helper.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ helper.checkUserExists = function (handle, api, dbConnectionMap, callback) {
16251625
* @param {Object} dbConnectionMap - the database connection map
16261626
* @param {Function<err>} callback - the callback function
16271627
*/
1628-
helper.checkUserActivated = function (handle, api, dbConnectionMap, callback) {
1628+
helper.checkUserActivated = function (handle, api, dbConnectionMap, callback, textResponse) {
16291629
api.dataAccess.executeQuery('check_user_activated', { handle: handle }, dbConnectionMap, function (err, result) {
16301630
if (err) {
16311631
callback(err, null);
@@ -1634,7 +1634,8 @@ helper.checkUserActivated = function (handle, api, dbConnectionMap, callback) {
16341634
if (result && result[0] && result[0].status === 'A') {
16351635
callback(err, null);
16361636
} else {
1637-
callback(err, new BadRequestError('User is not activated.'));
1637+
var message = textResponse || 'User is not activated.';
1638+
callback(err, new BadRequestError(message));
16381639
}
16391640
});
16401641
};

0 commit comments

Comments
 (0)