Fix crash when org check is empty, run once weekly (#58281)

This commit is contained in:
Andrew Branch
2022-01-18 11:01:07 -08:00
committed by GitHub
parent fad9862b5e
commit c609479376
2 changed files with 13 additions and 7 deletions

View File

@@ -103,11 +103,17 @@ async function fetchGhosts(users) {
}
// Filter out organizations
const query = `query {
${ghosts.map((user, i) => `o${i}: organization(login: "${user}") { id }`).join("\n")}
}`;
const result = await tryGQL(() => octokit.graphql(query));
return new Set(ghosts.filter(g => result.data[`o${ghosts.indexOf(g)}`] === null));
if (ghosts.length) {
const query = `query {
${ghosts.map((user, i) => `o${i}: organization(login: "${user}") { id }`).join("\n")}
}`;
const result = await tryGQL(() => octokit.graphql(query));
if (result.data) {
return new Set(ghosts.filter(g => result.data[`o${ghosts.indexOf(g)}`] === null));
}
}
return new Set(ghosts);
}
/**