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

Commit 80ca25a

Browse files
committed
return challenges with challenge name including primary technology
1 parent 458f501 commit 80ca25a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

actions/challenges.js

Lines changed: 16 additions & 4 deletions
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;

0 commit comments

Comments
 (0)