From b164ac0241aba59be012e15bb1f3425bcc62639b Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Tue, 16 Apr 2024 12:09:31 +0200 Subject: [PATCH] enhance(algolia): sort dashed entities to the top of `availableEntityNames` array --- baker/algolia/indexChartsToAlgolia.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/baker/algolia/indexChartsToAlgolia.ts b/baker/algolia/indexChartsToAlgolia.ts index 8d2475ec7d7..e7e4e8cd7f2 100644 --- a/baker/algolia/indexChartsToAlgolia.ts +++ b/baker/algolia/indexChartsToAlgolia.ts @@ -38,6 +38,8 @@ const processAvailableEntities = (availableEntities: string[] | null) => { // if "USA" is within the first 100-or-so entries of the array. // So, the easy solution is to sort the entities to ensure that countries // with variant names are at the top. + // Also, entities containing a hyphen like "low-income countries" can also + // only be found if they're within the first 100-or-so entries. // - @marcelgerber, 2024-03-25 return orderBy( availableEntities, @@ -46,9 +48,10 @@ const processAvailableEntities = (availableEntities: string[] | null) => { countriesWithVariantNames.has( removeTrailingParenthetical(entityName) ), + (entityName) => entityName.includes("-"), (entityName) => entityName, ], - ["desc", "asc"] + ["desc", "desc", "asc"] ) }