Skip to content

Filter update #288

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 7 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- attach_workspace:
at: .
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run: npm publish
- run: npm publish --tag test-release
# dont change anything
workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .",
"test": "npm run lint && npm run jest"
},
"version": "1.1.3",
"version": "1000.26.1",
"dependencies": {
"auth0-js": "^6.8.4",
"config": "^3.2.0",
Expand Down
3 changes: 2 additions & 1 deletion src/services/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ class ChallengesService {
filter,
) => {
let res = {};
if (_.some(filter.frontFilter.tracks, val => val)) {
if (_.some(filter.frontFilter.tracks, val => val)
&& !_.isEqual(filter.frontFilter.types, [])) {
const query = getFilterUrl(filter.backendFilter, filter.frontFilter);
const url = `${endpoint}?${query}`;
res = await this.private.apiV5.get(url).then(checkErrorV5);
Expand Down
20 changes: 11 additions & 9 deletions src/utils/challenge/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ function filterByRegistrationOpen(challenge, state) {
* @return {Boolean} True if opp satifies the filter
*/
function filterByReviewOpportunityType(opp, state) {
if (!state.reviewOpportunityType) return true;
return opp.type === state.reviewOpportunityType;
if (state.reviewOpportunityTypes.length === 0) return false;
return state.reviewOpportunityTypes.includes(opp.type);
}

function filterByStartDate(challenge, state) {
Expand Down Expand Up @@ -158,10 +158,10 @@ function filterByEvents(challenge, state) {
}

function filterByText(challenge, state) {
if (!state.name) return true;
if (!state.search) return true;
const str = `${challenge.name} ${challenge.tags} ${challenge.platforms} ${challenge.tags}`
.toLowerCase();
return str.includes(state.name.toLowerCase());
return str.includes(state.search.toLowerCase());
}

function filterByTrack(challenge, state) {
Expand Down Expand Up @@ -447,14 +447,16 @@ export function setEndDate(state, date) {
/**
* Clones the state and sets the review opportunity type.
* @param {Object} state
* @param {Array} reviewOpportunityType Possible values found in utils/tc REVIEW_OPPORTUNITY_TYPES
* @param {Array} reviewOpportunityTypes Possible values found in utils/tc REVIEW_OPPORTUNITY_TYPES
* @return {Object}
*/
export function setReviewOpportunityType(state, reviewOpportunityType) {
if (reviewOpportunityType) return { ...state, reviewOpportunityType };
if (!state.reviewOpportunityType) return state;
export function setReviewOpportunityType(state, reviewOpportunityTypes) {
if (reviewOpportunityTypes && reviewOpportunityTypes.length) {
return { ...state, reviewOpportunityTypes };
}
if (!state.reviewOpportunityTypes) return state;
const res = _.clone(state);
delete res.reviewOpportunityType;
delete res.reviewOpportunityTypes;
return res;
}

Expand Down