diff --git a/src/datasource/wikitree.ts b/src/datasource/wikitree.ts index 0bb7c8e..b71137e 100644 --- a/src/datasource/wikitree.ts +++ b/src/datasource/wikitree.ts @@ -12,8 +12,8 @@ import { import {StringUtils} from 'turbocommons-ts'; import { clientLogin, - getAncestors as getAncestorsApi, getLoggedInUserName, + getPeople, getRelatives as getRelativesApi, Person, } from 'wikitree-js'; @@ -67,12 +67,19 @@ async function getAncestors( key: string, handleCors: boolean, ): Promise { + // Limit the number of generations of ancestors. + const ancestorsGenerationLimit = 5; + const cacheKey = `wikitree:ancestors:${key}`; const cachedData = getSessionStorageItem(cacheKey); if (cachedData) { return JSON.parse(cachedData); } - const result = await getAncestorsApi(key, {}, getApiOptions(handleCors)); + const result = await getPeople( + [key], + {ancestors: ancestorsGenerationLimit}, + getApiOptions(handleCors), + ); setSessionStorageItem(cacheKey, JSON.stringify(result)); return result; }