From 7e6be9bac2981c8e3b8d73a1f3f07af6e000e1d7 Mon Sep 17 00:00:00 2001 From: Henrique Pinheiro Date: Wed, 24 Jan 2024 15:33:15 -0300 Subject: [PATCH] Cria `flatScientificName` Fixes #63 --- src/fauna.ts | 6 +++++- src/flora.ts | 6 +++++- src/ocorrencia.ts | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/fauna.ts b/src/fauna.ts index 8566659..b8caf33 100644 --- a/src/fauna.ts +++ b/src/fauna.ts @@ -79,6 +79,9 @@ export const processaFauna = (dwcJson: FaunaJson): FaunaJson => { ] .filter(Boolean) .join(' ') + taxon.flatScientificName = (taxon.scientificName as string) + .replace(/[^a-zA-Z0-9]/, '') + .toLocaleLowerCase() entries.push([id, taxon]) return entries @@ -149,7 +152,8 @@ async function main() { { key: { canonicalName: 1 }, name: 'canonicalName' - } + }, + { key: { flatScientificName: 1 }, name: 'flatScientificName' } ] }) console.debug('Done') diff --git a/src/flora.ts b/src/flora.ts index 9969e1d..5f89482 100644 --- a/src/flora.ts +++ b/src/flora.ts @@ -80,6 +80,9 @@ export const processaFlora = (dwcJson: FloraJson): FloraJson => { ] .filter(Boolean) .join(' ') + taxon.flatScientificName = (taxon.scientificName as string) + .replace(/[^a-zA-Z0-9]/, '') + .toLocaleLowerCase() entries.push([id, taxon]) return entries @@ -154,7 +157,8 @@ async function main() { { key: { canonicalName: 1 }, name: 'canonicalName' - } + }, + { key: { flatScientificName: 1 }, name: 'flatScientificName' } ] }) console.debug('Done') diff --git a/src/ocorrencia.ts b/src/ocorrencia.ts index fe436ac..2543e9d 100644 --- a/src/ocorrencia.ts +++ b/src/ocorrencia.ts @@ -64,7 +64,8 @@ await Promise.all([ key: { ipt: 1 }, name: 'ipt' }, - { key: { canonicalName: 1 }, name: 'canonicalName' } + { key: { canonicalName: 1 }, name: 'canonicalName' }, + { key: { flatScientificName: 1 }, name: 'flatScientificName' } ]), iptsCol.createIndexes([ { @@ -123,6 +124,9 @@ for (const { ipt: iptName, baseUrl, datasets } of iptSources) { ] .filter(Boolean) .join(' '), + flatScientificName: (ocorrencia[1].scientificName as string) + .replace(/[^a-zA-Z0-9]/, '') + .toLocaleLowerCase(), ...ocorrencia[1] })), {