Skip to content

Commit ebb4418

Browse files
committed
Move engagement type filter into filters block
1 parent 0023b83 commit ebb4418

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/components/engagement/engagement.repository.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { Injectable } from '@nestjs/common';
22
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';
411
import { difference, pickBy } from 'lodash';
512
import { DateTime } from 'luxon';
613
import { MergeExclusive } from 'type-fest';
@@ -336,20 +343,14 @@ export class EngagementRepository extends CommonRepository {
336343
// LIST ///////////////////////////////////////////////////////////
337344

338345
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-
345346
const result = await this.db
346347
.query()
347348
.subQuery((sub) =>
348349
sub
349350
.match([
350351
node('project', 'Project', pickBy({ id: input.filter?.projectId })),
351352
relation('out', '', 'engagement', ACTIVE),
352-
node('node', label),
353+
node('node', 'Engagement'),
353354
])
354355
.apply(whereNotDeletedInChangeset(changeset))
355356
.return(['node', 'project'])
@@ -360,7 +361,7 @@ export class EngagementRepository extends CommonRepository {
360361
.match([
361362
node('project', 'Project', { id: input.filter.projectId }),
362363
relation('out', '', 'engagement', INACTIVE),
363-
node('node', label),
364+
node('node', 'Engagement'),
364365
relation('in', '', 'changeset', ACTIVE),
365366
node('changeset', 'Changeset', { id: changeset }),
366367
])
@@ -512,7 +513,14 @@ export class EngagementRepository extends CommonRepository {
512513
}
513514

514515
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+
}),
516524
projectId: filter.skip,
517525
partnerId: filter.pathExists((id) => [
518526
node('node'),

0 commit comments

Comments
 (0)