Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 33 additions & 20 deletions pwa/api/contributorsRank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,29 +145,42 @@ export const getAllContributors = async () => {
);
const allContributors = await Promise.all(
sortedContributors.map(async (contributor) => {
const { data } = await octokit.rest.users.getByUsername({
username: contributor.login || "",
});
if (data.blog) {
data.blog = addHttpsToUrls(data.blog);
}
try {
const { data } = await octokit.rest.users.getByUsername({
username: contributor.login || "",
});
if (data.blog) {
data.blog = addHttpsToUrls(data.blog);
}

return {
login: data.login,
repos: contributor.repos,
rank: contributor.rank,
contributions: contributor.contributions,
isCoreTeam: contributor.isCoreTeam,
avatar_url: contributor.avatar_url,
bio: data.bio,
name: data.name,
location: data.location,
company: data.company,
blog: data.blog,
};
return {
login: data.login,
repos: contributor.repos,
rank: contributor.rank,
contributions: contributor.contributions,
isCoreTeam: contributor.isCoreTeam,
avatar_url: contributor.avatar_url,
bio: data.bio,
name: data.name,
location: data.location,
company: data.company,
blog: data.blog,
};
} catch (e: any) {
// Some accounts (e.g. the Copilot bot) have no public user
// profile and return 404. Skip them instead of failing the
// whole run, which would wipe the entire dataset.
if (e?.status === 404) {
console.warn(
`Skipping contributor without a user profile: ${contributor.login}`
);
return null;
}
throw e;
}
})
);
return allContributors;
return allContributors.filter(Boolean);
} catch (e) {
console.error(e);
return [];
Expand Down
Loading
Loading