mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-04-14 10:36:16 +00:00
Limit the number of WikiTree generations to 10
This commit is contained in:
@@ -186,9 +186,14 @@ export async function loadWikiTree(
|
|||||||
const ancestorDetails = await getRelatives(ancestorKeys, handleCors);
|
const ancestorDetails = await getRelatives(ancestorKeys, handleCors);
|
||||||
everyone.push(...ancestorDetails);
|
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.
|
// Fetch descendants recursively.
|
||||||
let toFetch = [key];
|
let toFetch = [key];
|
||||||
while (toFetch.length > 0) {
|
let generation = 0;
|
||||||
|
while (toFetch.length > 0 && generation <= descendantGenerationLimit) {
|
||||||
const people = await getRelatives(toFetch, handleCors);
|
const people = await getRelatives(toFetch, handleCors);
|
||||||
everyone.push(...people);
|
everyone.push(...people);
|
||||||
const allSpouses = people.flatMap((person) =>
|
const allSpouses = people.flatMap((person) =>
|
||||||
@@ -199,6 +204,7 @@ export async function loadWikiTree(
|
|||||||
toFetch = people.flatMap((person) =>
|
toFetch = people.flatMap((person) =>
|
||||||
Object.values(person.Children).map((c) => c.Name),
|
Object.values(person.Children).map((c) => c.Name),
|
||||||
);
|
);
|
||||||
|
generation++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map from person id to the set of families where they are a spouse.
|
// Map from person id to the set of families where they are a spouse.
|
||||||
|
|||||||
Reference in New Issue
Block a user