Skip to content

Commit 4f4fbfb

Browse files
authored
Add Language.population sorting (#3404)
1 parent 515676b commit 4f4fbfb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/components/language/language.repository.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { DtoRepository, OnIndex, UniquenessError } from '~/core/database';
2424
import {
2525
ACTIVE,
2626
any,
27+
coalesce,
2728
collect,
2829
createNode,
2930
createRelationships,
@@ -398,6 +399,23 @@ export const languageSorters = defineSorters(Language, {
398399
['registryOfDialectsCode' as any]: propSorter(
399400
'registryOfLanguageVarietiesCode',
400401
),
402+
population: (query) =>
403+
query
404+
.match([
405+
node('node'),
406+
relation('out', '', 'populationOverride', ACTIVE),
407+
node('override'),
408+
])
409+
.match([
410+
node('node'),
411+
relation('out', '', 'ethnologue'),
412+
node('', 'EthnologueLanguage'),
413+
relation('out', '', 'population', ACTIVE),
414+
node('canonical'),
415+
])
416+
.return<{ sortValue: unknown }>(
417+
coalesce('override.value', 'canonical.value').as('sortValue'),
418+
),
401419
});
402420

403421
const ethnologueSorters = defineSorters(EthnologueLanguage, {});

0 commit comments

Comments
 (0)