Skip to content

Commit

Permalink
replace the '/stats/contributors' endpoint with ' /contributors' endp…
Browse files Browse the repository at this point in the history
…oint to avoid timing issue during the computation phase on github servers
  • Loading branch information
activus-d committed Dec 16, 2024
1 parent 6249e3f commit c79c2a9
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ interface Contributor {
}

interface GitHubContributor {
author: {
id: number;
login: string;
avatar_url: string;
};
total: number;
id: number;
login: string;
avatar_url: string;
contributions: number;
}

export async function getContributors() {
const url = `https://api.github.com/repos/${owner}/${repo}/stats/contributors`;
const url = `https://api.github.com/repos/${owner}/${repo}/contributors`;
const contributorsRes = await fetchData(owner, repo, url);
const contributors = await contributorsRes.json();

Expand All @@ -35,10 +33,10 @@ export async function getContributors() {

return contributors
.map((contributor: GitHubContributor) => ({
id: contributor.author.id,
name: contributor.author.login,
commits: contributor.total,
avatarUrl: contributor.author.avatar_url,
id: contributor.id,
name: contributor.login,
commits: contributor.contributions,
avatarUrl: contributor.avatar_url,
}))
.sort((a: Contributor, b: Contributor) => b.commits - a.commits);
}

0 comments on commit c79c2a9

Please sign in to comment.