@@ -90,7 +90,7 @@ function filterByRegistrationOpen(challenge, state) {
90
90
if ( ! registrationPhase || ! registrationPhase . isOpen ) {
91
91
return false ;
92
92
}
93
- if ( challenge . track === COMPETITION_TRACKS . DESIGN ) {
93
+ if ( challenge . track === COMPETITION_TRACKS . DES ) {
94
94
const checkpointPhase = challengePhases . find ( item => item . name === 'Checkpoint Submission' ) [ 0 ] ;
95
95
return ! checkpointPhase || ! checkpointPhase . isOpen ;
96
96
}
@@ -147,7 +147,7 @@ function filterByStatus(challenge, state) {
147
147
function filterByTags ( challenge , state ) {
148
148
if ( _ . isEmpty ( state . tags ) ) return true ;
149
149
const { platforms, tags } = challenge ;
150
- const str = `${ platforms } ${ tags } ` . toLowerCase ( ) ;
150
+ const str = `${ platforms . join ( ' ' ) } ${ tags . join ( ' ' ) } ` . toLowerCase ( ) ;
151
151
return state . tags . some ( tag => str . includes ( tag . toLowerCase ( ) ) ) ;
152
152
}
153
153
@@ -158,19 +158,20 @@ function filterByEvents(challenge, state) {
158
158
}
159
159
160
160
function filterByText ( challenge , state ) {
161
- if ( ! state . text ) return true ;
161
+ if ( ! state . name ) return true ;
162
162
const str = `${ challenge . name } ${ challenge . tags } ${ challenge . platforms } ${ challenge . tags } `
163
163
. toLowerCase ( ) ;
164
- return str . includes ( state . text . toLowerCase ( ) ) ;
164
+ return str . includes ( state . name . toLowerCase ( ) ) ;
165
165
}
166
166
167
167
function filterByTrack ( challenge , state ) {
168
- if ( ! state . tracks ) return true ;
169
- return _ . keys ( state . tracks ) . some ( track => challenge . track === track ) ;
168
+ // if (!state.tracks) return true;
169
+ // eslint-disable-next-line max-len
170
+ return state . tracks [ challenge . track ] === true ;
170
171
}
171
172
172
173
function filterByTypes ( challenge , state ) {
173
- if ( ! state . types ) return true ;
174
+ if ( state . types . length === 0 ) return true ;
174
175
return state . types . includes ( challenge . typeId ) ;
175
176
}
176
177
@@ -179,10 +180,10 @@ function filterByUpcoming(challenge, state) {
179
180
return moment ( ) . isBefore ( challenge . registrationStartDate ) ;
180
181
}
181
182
182
- function filterByUsers ( challenge , state ) {
183
- if ( ! state . userChallenges ) return true ;
184
- return state . userChallenges . find ( ch => challenge . id === ch ) ;
185
- }
183
+ // function filterByUsers(challenge, state) {
184
+ // if (!state.userChallenges) return true;
185
+ // return state.userChallenges.find(ch => challenge.id === ch);
186
+ // }
186
187
187
188
/**
188
189
* Returns clone of the state with the specified competition track added.
@@ -223,7 +224,7 @@ export function getFilterFunction(state) {
223
224
&& filterByTags ( challenge , state )
224
225
&& filterByEvents ( challenge , state )
225
226
&& filterByTypes ( challenge , state )
226
- && filterByUsers ( challenge , state )
227
+ // && filterByUsers(challenge, state)
227
228
&& filterByEndDate ( challenge , state )
228
229
&& filterByStartDate ( challenge , state )
229
230
&& filterByStarted ( challenge , state )
@@ -247,7 +248,14 @@ export function getFilterFunction(state) {
247
248
*/
248
249
export function getReviewOpportunitiesFilterFunction ( state , validTypes ) {
249
250
return ( opp ) => {
250
- const newType = _ . find ( validTypes , { name : opp . challenge . type } ) || { } ;
251
+ const trackAbbr = {
252
+ 'Data Science' : 'DS' ,
253
+ Development : 'Dev' ,
254
+ Design : 'Des' ,
255
+ 'Quality Assurance' : 'QA' ,
256
+ } ;
257
+ // const newType = _.find(validTypes, { name: opp.challenge.type }) || {};
258
+ const newType = _ . find ( validTypes , { name : opp . challenge . subTrack === 'FIRST_2_FINISH' ? 'First2Finish' : 'Challenge' } ) || { } ;
251
259
252
260
// Review Opportunity objects have a challenge field which
253
261
// is largely compatible with many of the existing filter functions
@@ -256,21 +264,32 @@ export function getReviewOpportunitiesFilterFunction(state, validTypes) {
256
264
...opp . challenge ,
257
265
// This allows filterByText to search for Review Types and Challenge Titles
258
266
name : `${ opp . challenge . title } ${ REVIEW_OPPORTUNITY_TYPES [ opp . type ] } ` ,
259
- registrationStartDate : opp . startDate , // startDate of Review, not Challenge
260
- submissionEndDate : opp . startDate , // Currently uses startDate for both date comparisons
261
- communities : new Set ( [ // Used to filter by Track, and communities at a future date
262
- opp . challenge . track . toLowerCase ( ) ,
263
- ] ) ,
264
- typeId : newType . id ,
267
+ // registrationStartDate: opp.startDate, // startDate of Review, not Challenge
268
+ // submissionEndDate: opp.startDate, // Currently uses startDate for both date comparisons
269
+ // communities: new Set([ // Used to filter by Track, and communities at a future date
270
+ // opp.challenge.track === 'QA' ? 'Dev' : trackAbbr[opp.challenge.track],
271
+ // ]),
272
+ track : trackAbbr [ opp . challenge . track ] ,
273
+ typeId : newType . abbreviation ,
265
274
tags : opp . challenge . technologies || [ ] ,
266
275
platforms : opp . challenge . platforms || [ ] ,
267
276
} ;
268
-
277
+ /**
278
+ console.log(challenge);
279
+ console.log(`=====`);
280
+ console.log(`11111`);
281
+ console.log(filterByTrack(challenge, state));
282
+ console.log(filterByText(challenge, state));
283
+ console.log(filterByTags(challenge, state));
284
+ console.log(filterByEndDate(challenge, state));
285
+ console.log(filterByStartDate(challenge, state));
286
+ console.log(filterByReviewOpportunityType(opp, state));
287
+ */
269
288
return (
270
289
filterByTrack ( challenge , state )
271
290
&& filterByText ( challenge , state )
272
291
&& filterByTags ( challenge , state )
273
- // && filterByTypes(challenge, state)
292
+ && filterByTypes ( challenge , state )
274
293
&& filterByEndDate ( challenge , state )
275
294
&& filterByStartDate ( challenge , state )
276
295
&& filterByReviewOpportunityType ( opp , state )
0 commit comments