Skip to content

Commit

Permalink
fix: only show real contributor in Thank You box
Browse files Browse the repository at this point in the history
  • Loading branch information
zdtsw committed Jul 6, 2022
1 parent 979150c commit 1bb9aad
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/hooks/useAdoptiumContributorsApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,23 @@ async function getMaxContributors(): Promise<[number, number]> {

/**
* Retrieves a contributor's object by it's index in API
* only return 'type: User' to filter out Bot
* @param randomPage
*/
async function getContributor(randomPage: number): Promise<Contributor> {
const response = await fetch(`${CONTRIBUTORS_API_URI}&page=${randomPage}`);
const contributor = (await response.json())[0] as ContributorApiResponse;

return {
avatarUri: contributor.avatar_url,
commitsListUri: `https://github.com/adoptium/${repoToCheck}/commits?author=${contributor.login}`,
repo: repoToCheck,
contributionsCount: contributor.contributions,
login: contributor.login,
profileUri: contributor.html_url,
};
const responseJsonData = await response.json()
if ( responseJsonData.type == "User" ) {
const contributor = responseJsonData.id as ContributorApiResponse;
return {
avatarUri: contributor.avatar_url,
commitsListUri: `https://github.com/adoptium/${repoToCheck}/commits?author=${contributor.login}`,
repo: repoToCheck,
contributionsCount: contributor.contributions,
login: contributor.login,
profileUri: contributor.html_url,
};
}
}

/**
Expand Down

0 comments on commit 1bb9aad

Please sign in to comment.