@@ -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 } `
@@ -214,6 +221,7 @@ export function getFilterFunction(state) {
214
221
&& filterByGroupIds ( challenge , state )
215
222
&& filterByText ( challenge , state )
216
223
&& filterByTags ( challenge , state )
224
+ && filterByEvents ( challenge , state )
217
225
&& filterByTypes ( challenge , state )
218
226
&& filterByUsers ( challenge , state )
219
227
&& filterByEndDate ( challenge , state )
@@ -343,7 +351,7 @@ export function combine(...filters) {
343
351
const res = { } ;
344
352
filters . forEach ( ( filter ) => {
345
353
combineEndDate ( res , filter ) ;
346
- combineArrayRules ( res , filter , 'groups ' ) ;
354
+ combineArrayRules ( res , filter , 'groupIds ' ) ;
347
355
/* TODO: The registrationOpen rule is just ignored for now. */
348
356
combineStartDate ( res , filter ) ;
349
357
combineArrayRules ( res , filter , 'or' , true ) ;
@@ -380,7 +388,7 @@ export function combine(...filters) {
380
388
*/
381
389
export function mapToBackend ( filter ) {
382
390
const res = { } ;
383
- if ( filter . groups ) res . groups = filter . groups ;
391
+ if ( filter . groupIds ) res . groups = filter . groupIds ;
384
392
return res ;
385
393
}
386
394
0 commit comments