Limit the number of WikiTree generations to 10

This commit is contained in:
Przemek Wiech 2020-02-03 15:33:26 +01:00
parent 6acd00d79b
commit 423cd42676

View File

@ -186,9 +186,14 @@ export async function loadWikiTree(
const ancestorDetails = await getRelatives(ancestorKeys, handleCors);
everyone.push(...ancestorDetails);
// Limit the number of generations of descendants because there may be tens of
// generations for some profiles.
const descendantGenerationLimit = 10;
// Fetch descendants recursively.
let toFetch = [key];
while (toFetch.length > 0) {
let generation = 0;
while (toFetch.length > 0 && generation <= descendantGenerationLimit) {
const people = await getRelatives(toFetch, handleCors);
everyone.push(...people);
const allSpouses = people.flatMap((person) =>
@ -199,6 +204,7 @@ export async function loadWikiTree(
toFetch = people.flatMap((person) =>
Object.values(person.Children).map((c) => c.Name),
);
generation++;
}
// Map from person id to the set of families where they are a spouse.