Skip to content

Commit f8a1092

Browse files
authored
Implement sorting for engagement start/end date (#3256)
1 parent b56eec6 commit f8a1092

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/components/engagement/engagement.repository.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Query,
99
relation,
1010
} from 'cypher-query-builder';
11-
import { difference, pickBy } from 'lodash';
11+
import { difference, pickBy, upperFirst } from 'lodash';
1212
import { DateTime } from 'luxon';
1313
import { MergeExclusive } from 'type-fest';
1414
import {
@@ -609,6 +609,26 @@ export const engagementSorters = defineSorters(IEngagement, {
609609
.match([node('project'), relation('out', '', 'engagement'), node('node')])
610610
.apply(matchProjectSens())
611611
.return<{ sortValue: unknown }>('sensitivity as sortValue'),
612+
...mapValues.fromList(
613+
['startDate', 'endDate'],
614+
(field) => (query: Query) =>
615+
query
616+
.optionalMatch([
617+
node('node'),
618+
relation('out', '', `${field}Override`, ACTIVE),
619+
node('override', 'Property'),
620+
])
621+
.optionalMatch([
622+
node('node'),
623+
relation('in', '', 'engagement'),
624+
node('project'),
625+
relation('out', '', `mou${upperFirst(field.slice(0, -4))}`, ACTIVE),
626+
node('projProp'),
627+
])
628+
.return<{ sortValue: unknown }>(
629+
coalesce('override.value', 'projProp.value').as('sortValue'),
630+
),
631+
).asRecord,
612632
// eslint-disable-next-line @typescript-eslint/naming-convention
613633
'language.*': (query, input) =>
614634
query

0 commit comments

Comments
 (0)