@@ -159,20 +159,12 @@ function filterByText(challenge, state) {
159
159
160
160
function filterByTrack ( challenge , state ) {
161
161
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 ) ;
171
163
}
172
164
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 ) ;
176
168
}
177
169
178
170
function filterByUpcoming ( challenge , state ) {
@@ -222,7 +214,7 @@ export function getFilterFunction(state) {
222
214
&& filterByGroupIds ( challenge , state )
223
215
&& filterByText ( challenge , state )
224
216
&& filterByTags ( challenge , state )
225
- && filterBySubtracks ( challenge , state )
217
+ && filterByTypes ( challenge , state )
226
218
&& filterByUsers ( challenge , state )
227
219
&& filterByEndDate ( challenge , state )
228
220
&& filterByStartDate ( challenge , state )
@@ -245,9 +237,9 @@ export function getFilterFunction(state) {
245
237
* @param {Object } state
246
238
* @return {Function }
247
239
*/
248
- export function getReviewOpportunitiesFilterFunction ( state , validSubtracks ) {
240
+ export function getReviewOpportunitiesFilterFunction ( state , validTypes ) {
249
241
return ( opp ) => {
250
- const newSubTrack = _ . find ( validSubtracks , { abbreviation : opp . challenge . subTrack } ) || { } ;
242
+ const newType = _ . find ( validTypes , { name : opp . challenge . type } ) || { } ;
251
243
252
244
// Review Opportunity objects have a challenge field which
253
245
// is largely compatible with many of the existing filter functions
@@ -257,12 +249,11 @@ export function getReviewOpportunitiesFilterFunction(state, validSubtracks) {
257
249
// This allows filterByText to search for Review Types and Challenge Titles
258
250
name : `${ opp . challenge . title } ${ REVIEW_OPPORTUNITY_TYPES [ opp . type ] } ` ,
259
251
registrationStartDate : opp . startDate , // startDate of Review, not Challenge
260
- subTrack : opp . challenge . subTrack || '' , // Sometimes back-end doesn't return this field
261
252
submissionEndDate : opp . startDate , // Currently uses startDate for both date comparisons
262
253
communities : new Set ( [ // Used to filter by Track, and communities at a future date
263
254
opp . challenge . track . toLowerCase ( ) ,
264
255
] ) ,
265
- typeId : newSubTrack . id ,
256
+ typeId : newType . id ,
266
257
tags : opp . challenge . technologies || [ ] ,
267
258
platforms : opp . challenge . platforms || [ ] ,
268
259
} ;
@@ -271,7 +262,7 @@ export function getReviewOpportunitiesFilterFunction(state, validSubtracks) {
271
262
filterByTrack ( challenge , state )
272
263
&& filterByText ( challenge , state )
273
264
&& filterByTags ( challenge , state )
274
- && filterBySubtracks ( challenge , state )
265
+ && filterByTypes ( challenge , state )
275
266
&& filterByEndDate ( challenge , state )
276
267
&& filterByStartDate ( challenge , state )
277
268
&& filterByReviewOpportunityType ( opp , state )
@@ -455,16 +446,16 @@ export function setStartDate(state, date) {
455
446
}
456
447
457
448
/**
458
- * Clones the state and sets the subtracks .
449
+ * Clones the state and sets the challenge types .
459
450
* @param {Object } state
460
- * @param {Array } subtracks
451
+ * @param {Array } types
461
452
* @return {Object }
462
453
*/
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 ;
466
457
const res = _ . clone ( state ) ;
467
- delete res . subtracks ;
458
+ delete res . types ;
468
459
return res ;
469
460
}
470
461
0 commit comments