Skip to content

Commit

Permalink
filter bots from response and fix site crash on ratelimit
Browse files Browse the repository at this point in the history
  • Loading branch information
AnilSeervi committed Oct 2, 2022
1 parent ac957d7 commit 26532f6
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions docs/src/pages/support.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { useState } from 'react';
import Link from '@docusaurus/Link';
import { useEffect } from 'react';

const CONTRIBUTORS_API = 'https://api.github.com/repos/kimlimjustin/xplorer/contributors';
const BOTS_ID = [49699333, 62050782, 60907429]; // dependabot[bot] and deepsource[bot] are not real contributors
const CONTRIBUTORS_API = 'https://api.github.com/repos/kimlimjustin/xplorer/contributors'; // fetches atmost 30 contributors from github

const Support = () => {
const [contributors, setContributors] = useState([]);
useEffect(() => {
fetch(CONTRIBUTORS_API)
.then((response) => response.json())
.then((data) => setContributors(data));
.then((data) => setContributors(data.filter((contributor) => !BOTS_ID.includes(contributor.id))));
}, []);

return (
Expand All @@ -29,24 +30,21 @@ const Support = () => {
</Link>
</p>
<div className="supports-contributors">
{contributors.slice(0, 50).map(
(contributor) =>
contributor.login !== "dependabot[bot]" && (
<Link to={contributor.html_url} key={contributor.id}>
<div className="supports-contributor">
<img
className="supports-contributor-image"
src={contributor.avatar_url}
alt={`${contributor.login} has contributed ${contributor.contributions} times to Xplorer`}
/>
<div className="supports-contributor-info">
<span className="supports-contributor-name">{contributor.login}</span>
<span className="supports-contributor-count">{contributor.contributions} contributions</span>
</div>
</div>
</Link>
)
)}
{contributors.map((contributor) => (
<Link to={contributor.html_url} key={contributor.id}>
<div className="supports-contributor">
<img
className="supports-contributor-image"
src={contributor.avatar_url}
alt={`${contributor.login} has contributed ${contributor.contributions} times to Xplorer`}
/>
<div className="supports-contributor-info">
<span className="supports-contributor-name">{contributor.login}</span>
<span className="supports-contributor-count">{contributor.contributions} contributions</span>
</div>
</div>
</Link>
))}
</div>
</div>
);
Expand Down

0 comments on commit 26532f6

Please sign in to comment.