Skip to content

Update filter object for fetch Data Science challenges #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2019
Merged
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
14 changes: 10 additions & 4 deletions src/actions/challenge-listing.js
Original file line number Diff line number Diff line change
@@ -19,18 +19,24 @@ const { PAGE_SIZE, REVIEW_OPPORTUNITY_PAGE_SIZE } = config;

/**
* Process filter
* Development challenges having Data Science tech tag, still should be
* included into data science track.
* When filter includes Data Science track, still should be
* included DEVELOP_MARATHON_MATCH sub track.
* @param filter
* @returns {string}
*/
function processFilter(filter) {
const newFilter = _.clone(filter);
if (_.has(filter, 'track')
&& filter.track.includes(COMPETITION_TRACKS.DATA_SCIENCE.toUpperCase())
&& !filter.track.includes(COMPETITION_TRACKS.DEVELOP.toUpperCase())
&& ((_.has(filter, 'subTrack') && !filter.subTrack.includes('DEVELOP_MARATHON_MATCH'))
|| !_.has(filter, 'subTrack'))
) {
newFilter.track = `${newFilter.track},${COMPETITION_TRACKS.DEVELOP.toUpperCase()}`;
newFilter.subTrack = `${_.has(filter, 'subTrack') ? `${newFilter.subTrack},DEVELOP_MARATHON_MATCH` : 'DEVELOP_MARATHON_MATCH'}`;
newFilter.track = _.remove(filter.track.split(','), item => item.toUpperCase() !== COMPETITION_TRACKS.DATA_SCIENCE.toUpperCase()).join(',');

if (_.isEmpty(newFilter.track)) {
delete newFilter.track;
}
}
return newFilter;
}