const ceoTitle = {
or: [
{ text: { current_title: "CEO" } },
{ text: { current_title: { value: "chief executive officer", mode: "all" } } },
],
};
const names = [...companies.values()];
const people = new Map();
for (let start = 0; start < names.length; start += 10) {
const batch = names.slice(start, start + 10);
const peopleResponse = await fetch(`${API}/people`, {
method: "POST",
headers: HEADERS,
body: JSON.stringify({
mode: "ludicrous",
query: {
and: [
ceoTitle,
{ or: batch.map((name) => ({ text: { current_company_name: { value: name, mode: "all" } } })) },
],
},
limit: 100,
view: { fields: ["current_title", "current_company_name", "current_company_id"] },
}),
});
if (!peopleResponse.ok) throw new Error(await peopleResponse.text());
for (const doc of (await peopleResponse.json()).documents) {
people.set(doc.bright_id, doc.data);
}
}
console.log(`${people.size} candidate profiles found`);