wildlife: fetch English names without the NL place (it localised them to Dutch)
All checks were successful
Deploy production / deploy (push) Successful in 1m6s
All checks were successful
Deploy production / deploy (push) Successful in 1m6s
This commit is contained in:
@@ -167,7 +167,8 @@ async function details(ids: number[], locale: 'en' | 'nl') {
|
|||||||
const out = new Map<number, InatTaxon>();
|
const out = new Map<number, InatTaxon>();
|
||||||
for (const [i, batch] of chunks(ids, 30).entries()) {
|
for (const [i, batch] of chunks(ids, 30).entries()) {
|
||||||
const res = await inat<{ results: InatTaxon[] }>(
|
const res = await inat<{ results: InatTaxon[] }>(
|
||||||
`/taxa/${batch.join(',')}?locale=${locale}&preferred_place_id=${PLACE_NL}`
|
// English names must not be localised to the NL place (that returns Dutch ones).
|
||||||
|
`/taxa/${batch.join(',')}?locale=${locale}${locale === 'nl' ? `&preferred_place_id=${PLACE_NL}` : ''}`
|
||||||
);
|
);
|
||||||
for (const t of res.results) out.set(t.id, t);
|
for (const t of res.results) out.set(t.id, t);
|
||||||
if (i % 20 === 0) log(` taxa (${locale}) ${Math.min((i + 1) * 30, ids.length)}/${ids.length}`);
|
if (i % 20 === 0) log(` taxa (${locale}) ${Math.min((i + 1) * 30, ids.length)}/${ids.length}`);
|
||||||
@@ -420,7 +421,7 @@ async function main() {
|
|||||||
nameNl = w.nl;
|
nameNl = w.nl;
|
||||||
if (!nameNl && w?.nl && w.nl.toLowerCase() !== t.name.toLowerCase()) nameNl = w.nl;
|
if (!nameNl && w?.nl && w.nl.toLowerCase() !== t.name.toLowerCase()) nameNl = w.nl;
|
||||||
if (nameNl) nameNl = nameNl.charAt(0).toUpperCase() + nameNl.slice(1);
|
if (nameNl) nameNl = nameNl.charAt(0).toUpperCase() + nameNl.slice(1);
|
||||||
const statuses = t.conservation_statuses ?? [];
|
const statuses = [...(tn?.conservation_statuses ?? []), ...(t.conservation_statuses ?? [])];
|
||||||
const global = statuses.find((s) => !s.place && s.authority === 'IUCN Red List');
|
const global = statuses.find((s) => !s.place && s.authority === 'IUCN Red List');
|
||||||
let iucn = global?.iucn != null ? (IUCN_BY_NUMBER[global.iucn] ?? null) : null;
|
let iucn = global?.iucn != null ? (IUCN_BY_NUMBER[global.iucn] ?? null) : null;
|
||||||
if (!iucn && global?.status && /^(LC|NT|VU|EN|CR|EW|EX|DD)$/i.test(global.status))
|
if (!iucn && global?.status && /^(LC|NT|VU|EN|CR|EW|EX|DD)$/i.test(global.status))
|
||||||
|
|||||||
Reference in New Issue
Block a user