Skip to content

Commit 640b884

Browse files
committed
Add sorting for Project.fieldRegion
1 parent 1925cc9 commit 640b884

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/components/project/project.repository.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
variable,
3535
} from '~/core/database/query';
3636
import { Privileges } from '../authorization';
37+
import { fieldRegionSorters } from '../field-region/field-region.repository';
3738
import { locationSorters } from '../location/location.repository';
3839
import { partnershipSorters } from '../partnership/partnership.repository';
3940
import {
@@ -456,4 +457,21 @@ export const projectSorters = defineSorters(IProject, {
456457
.where(not(path(getPath(true))))
457458
.return<SortCol>('null as sortValue');
458459
},
460+
// eslint-disable-next-line @typescript-eslint/naming-convention
461+
'fieldRegion.*': (query, input) => {
462+
const getPath = (anon = false) => [
463+
node('project'),
464+
relation('out', '', 'fieldRegion', ACTIVE),
465+
node(anon ? '' : 'node', 'FieldRegion'),
466+
];
467+
return query
468+
.with('node as project')
469+
.match(getPath())
470+
.apply(sortWith(fieldRegionSorters, input))
471+
.union()
472+
.with('node')
473+
.with('node as project')
474+
.where(not(path(getPath(true))))
475+
.return<SortCol>('null as sortValue');
476+
},
459477
});

0 commit comments

Comments
 (0)