Skip to content

Commit

Permalink
Merge pull request #927 from souvikpramanikgit/add-stylecontributor
Browse files Browse the repository at this point in the history
Contributors value showing wrong
  • Loading branch information
manikumarreddyu authored Nov 9, 2024
2 parents 9d1ac15 + 505d0f2 commit bc3cbb3
Showing 1 changed file with 31 additions and 17 deletions.
48 changes: 31 additions & 17 deletions frontend/src/pages/ContributorsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,46 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faGithub } from '@fortawesome/free-brands-svg-icons'
import CountUp from 'react-countup'
import axios from 'axios'

const ContributorsPage = () => {
const [contributors, setContributors] = useState([])
const [repoStats, setRepoStats] = useState({})
const [loading, setLoading] = useState(true)
const fetchData = async () => {
try {
const contributorsResponse = await fetch(
'https://api.github.com/repos/manikumarreddyu/AgroTech-AI/contributors'
)
const contributorsData = await contributorsResponse.json()

const repoResponse = await fetch(
'https://api.github.com/repos/manikumarreddyu/AgroTech-AI'
)
const repoData = await repoResponse.json()

setContributors(contributorsData)
setRepoStats(repoData)
const contributorsData = [];
const repoUrl = 'https://api.github.com/repos/manikumarreddyu/AgroTech-AI';
let page = 1;
let isFetching = true;

// Fetch repository stats
const repoResponse = await fetch(repoUrl);
const repoData = await repoResponse.json();
setRepoStats(repoData);

// Fetch all contributors with pagination
while (isFetching) {
const contributorsResponse = await fetch(`${repoUrl}/contributors?per_page=100&page=${page}`);
const pageData = await contributorsResponse.json();

if (!contributorsResponse.ok || pageData.length === 0) {
isFetching = false;
} else {
contributorsData.push(...pageData);
page++;
}
}

setContributors(contributorsData);
} catch (error) {
console.error('Error fetching data:', error)
setContributors([])
setRepoStats({})
console.error('Error fetching data:', error);
setContributors([]);
setRepoStats({});
} finally {
setLoading(false)
setLoading(false);
}
}
};


useEffect(() => {
fetchData()
Expand Down

0 comments on commit bc3cbb3

Please sign in to comment.