1
1
import { Injectable } from '@nestjs/common' ;
2
2
import { cleanJoin , mapValues , simpleSwitch } from '@seedcompany/common' ;
3
- import { inArray , node , Node , Query , relation } from 'cypher-query-builder' ;
3
+ import {
4
+ hasLabel ,
5
+ inArray ,
6
+ node ,
7
+ Node ,
8
+ Query ,
9
+ relation ,
10
+ } from 'cypher-query-builder' ;
4
11
import { difference , pickBy } from 'lodash' ;
5
12
import { DateTime } from 'luxon' ;
6
13
import { MergeExclusive } from 'type-fest' ;
@@ -336,20 +343,14 @@ export class EngagementRepository extends CommonRepository {
336
343
// LIST ///////////////////////////////////////////////////////////
337
344
338
345
async list ( input : EngagementListInput , session : Session , changeset ?: ID ) {
339
- const label =
340
- simpleSwitch ( input . filter ?. type , {
341
- language : 'LanguageEngagement' ,
342
- internship : 'InternshipEngagement' ,
343
- } ) ?? 'Engagement' ;
344
-
345
346
const result = await this . db
346
347
. query ( )
347
348
. subQuery ( ( sub ) =>
348
349
sub
349
350
. match ( [
350
351
node ( 'project' , 'Project' , pickBy ( { id : input . filter ?. projectId } ) ) ,
351
352
relation ( 'out' , '' , 'engagement' , ACTIVE ) ,
352
- node ( 'node' , label ) ,
353
+ node ( 'node' , 'Engagement' ) ,
353
354
] )
354
355
. apply ( whereNotDeletedInChangeset ( changeset ) )
355
356
. return ( [ 'node' , 'project' ] )
@@ -360,7 +361,7 @@ export class EngagementRepository extends CommonRepository {
360
361
. match ( [
361
362
node ( 'project' , 'Project' , { id : input . filter . projectId } ) ,
362
363
relation ( 'out' , '' , 'engagement' , INACTIVE ) ,
363
- node ( 'node' , label ) ,
364
+ node ( 'node' , 'Engagement' ) ,
364
365
relation ( 'in' , '' , 'changeset' , ACTIVE ) ,
365
366
node ( 'changeset' , 'Changeset' , { id : changeset } ) ,
366
367
] )
@@ -512,7 +513,14 @@ export class EngagementRepository extends CommonRepository {
512
513
}
513
514
514
515
export const engagementFilters = filter . define ( ( ) => EngagementFilters , {
515
- type : filter . skip ,
516
+ type : ( { value } ) => ( {
517
+ node : hasLabel (
518
+ simpleSwitch ( value , {
519
+ language : 'LanguageEngagement' ,
520
+ internship : 'InternshipEngagement' ,
521
+ } ) ! ,
522
+ ) ,
523
+ } ) ,
516
524
projectId : filter . skip ,
517
525
partnerId : filter . pathExists ( ( id ) => [
518
526
node ( 'node' ) ,
0 commit comments