@@ -159,20 +159,12 @@ function filterByText(challenge, state) {
159159
160160function filterByTrack ( challenge , state ) {
161161 if ( ! state . tracks ) return true ;
162-
163- /* Development challenges having Data Science tech tag, still should be
164- * included into data science track. */
165- if ( state . tracks [ COMPETITION_TRACKS . DATA_SCIENCE ]
166- && _ . includes ( challenge . tags , 'Data Science' ) ) {
167- return true ;
168- }
169-
170- return _ . keys ( state . tracks ) . some ( track => challenge . communities . has ( track ) ) ;
162+ return _ . keys ( state . tracks ) . some ( track => challenge . track === track ) ;
171163}
172164
173- function filterBySubtracks ( challenge , state ) {
174- if ( ! state . subtracks ) return true ;
175- return state . subtracks . includes ( challenge . typeId ) ;
165+ function filterByTypes ( challenge , state ) {
166+ if ( ! state . types ) return true ;
167+ return state . types . includes ( challenge . typeId ) ;
176168}
177169
178170function filterByUpcoming ( challenge , state ) {
@@ -222,7 +214,7 @@ export function getFilterFunction(state) {
222214 && filterByGroupIds ( challenge , state )
223215 && filterByText ( challenge , state )
224216 && filterByTags ( challenge , state )
225- && filterBySubtracks ( challenge , state )
217+ && filterByTypes ( challenge , state )
226218 && filterByUsers ( challenge , state )
227219 && filterByEndDate ( challenge , state )
228220 && filterByStartDate ( challenge , state )
@@ -245,9 +237,9 @@ export function getFilterFunction(state) {
245237 * @param {Object } state
246238 * @return {Function }
247239 */
248- export function getReviewOpportunitiesFilterFunction ( state , validSubtracks ) {
240+ export function getReviewOpportunitiesFilterFunction ( state , validTypes ) {
249241 return ( opp ) => {
250- const newSubTrack = _ . find ( validSubtracks , { abbreviation : opp . challenge . subTrack } ) || { } ;
242+ const newType = _ . find ( validTypes , { name : opp . challenge . type } ) || { } ;
251243
252244 // Review Opportunity objects have a challenge field which
253245 // is largely compatible with many of the existing filter functions
@@ -257,12 +249,11 @@ export function getReviewOpportunitiesFilterFunction(state, validSubtracks) {
257249 // This allows filterByText to search for Review Types and Challenge Titles
258250 name : `${ opp . challenge . title } ${ REVIEW_OPPORTUNITY_TYPES [ opp . type ] } ` ,
259251 registrationStartDate : opp . startDate , // startDate of Review, not Challenge
260- subTrack : opp . challenge . subTrack || '' , // Sometimes back-end doesn't return this field
261252 submissionEndDate : opp . startDate , // Currently uses startDate for both date comparisons
262253 communities : new Set ( [ // Used to filter by Track, and communities at a future date
263254 opp . challenge . track . toLowerCase ( ) ,
264255 ] ) ,
265- typeId : newSubTrack . id ,
256+ typeId : newType . id ,
266257 tags : opp . challenge . technologies || [ ] ,
267258 platforms : opp . challenge . platforms || [ ] ,
268259 } ;
@@ -271,7 +262,7 @@ export function getReviewOpportunitiesFilterFunction(state, validSubtracks) {
271262 filterByTrack ( challenge , state )
272263 && filterByText ( challenge , state )
273264 && filterByTags ( challenge , state )
274- && filterBySubtracks ( challenge , state )
265+ && filterByTypes ( challenge , state )
275266 && filterByEndDate ( challenge , state )
276267 && filterByStartDate ( challenge , state )
277268 && filterByReviewOpportunityType ( opp , state )
@@ -455,16 +446,16 @@ export function setStartDate(state, date) {
455446}
456447
457448/**
458- * Clones the state and sets the subtracks .
449+ * Clones the state and sets the challenge types .
459450 * @param {Object } state
460- * @param {Array } subtracks
451+ * @param {Array } types
461452 * @return {Object }
462453 */
463- export function setSubtracks ( state , subtracks ) {
464- if ( subtracks && subtracks . length ) return { ...state , subtracks } ;
465- if ( ! state . subtracks ) return state ;
454+ export function setTypes ( state , types ) {
455+ if ( types && types . length ) return { ...state , types } ;
456+ if ( ! state . types ) return state ;
466457 const res = _ . clone ( state ) ;
467- delete res . subtracks ;
458+ delete res . types ;
468459 return res ;
469460}
470461
0 commit comments