@@ -71,8 +71,9 @@ import { COMPETITION_TRACKS, REVIEW_OPPORTUNITY_TYPES } from '../tc';
71
71
*/
72
72
73
73
function filterByGroupIds ( challenge , state ) {
74
- if ( ! state . groupIds ) return true ;
75
- return state . groupIds . some ( id => challenge . groups [ id ] ) ;
74
+ if ( _ . isEmpty ( state . groupIds ) ) return true ;
75
+ if ( _ . isEmpty ( challenge . groups ) ) return false ;
76
+ return state . groupIds . some ( id => challenge . groups . find ( gId => gId === id ) ) ;
76
77
}
77
78
78
79
function filterByRegistrationOpen ( challenge , state ) {
@@ -144,12 +145,18 @@ function filterByStatus(challenge, state) {
144
145
}
145
146
146
147
function filterByTags ( challenge , state ) {
147
- if ( ! state . tags ) return true ;
148
+ if ( _ . isEmpty ( state . tags ) ) return true ;
148
149
const { platforms, tags } = challenge ;
149
150
const str = `${ platforms } ${ tags } ` . toLowerCase ( ) ;
150
151
return state . tags . some ( tag => str . includes ( tag . toLowerCase ( ) ) ) ;
151
152
}
152
153
154
+ function filterByEvents ( challenge , state ) {
155
+ if ( _ . isEmpty ( state . events ) ) return true ;
156
+ if ( _ . isEmpty ( challenge . events ) ) return false ;
157
+ return state . events . some ( key => challenge . events . find ( e => e . key === key ) ) ;
158
+ }
159
+
153
160
function filterByText ( challenge , state ) {
154
161
if ( ! state . text ) return true ;
155
162
const str = `${ challenge . name } ${ challenge . tags } ${ challenge . platforms } ${ challenge . tags } `
@@ -217,6 +224,7 @@ export function getFilterFunction(state) {
217
224
&& filterByGroupIds ( challenge , state )
218
225
&& filterByText ( challenge , state )
219
226
&& filterByTags ( challenge , state )
227
+ && filterByEvents ( challenge , state )
220
228
&& filterByTypes ( challenge , state )
221
229
&& filterByUsers ( challenge , state )
222
230
&& filterByEndDate ( challenge , state )
@@ -346,7 +354,7 @@ export function combine(...filters) {
346
354
const res = { } ;
347
355
filters . forEach ( ( filter ) => {
348
356
combineEndDate ( res , filter ) ;
349
- combineArrayRules ( res , filter , 'groups ' ) ;
357
+ combineArrayRules ( res , filter , 'groupIds ' ) ;
350
358
/* TODO: The registrationOpen rule is just ignored for now. */
351
359
combineStartDate ( res , filter ) ;
352
360
combineArrayRules ( res , filter , 'or' , true ) ;
@@ -383,7 +391,7 @@ export function combine(...filters) {
383
391
*/
384
392
export function mapToBackend ( filter ) {
385
393
const res = { } ;
386
- if ( filter . groups ) res . groups = filter . groups ;
394
+ if ( filter . groupIds ) res . groups = filter . groupIds ;
387
395
return res ;
388
396
}
389
397
0 commit comments