Skip to content

Commit

Permalink
Merge pull request #720 from akash70629/main
Browse files Browse the repository at this point in the history
💥FIX : Missing Total Contributions number on Contributors page
  • Loading branch information
swaraj-das authored Oct 31, 2024
2 parents 1b9c459 + 4df64ad commit f4454c9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions contributor/contributor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

// Fetch data from GitHub API
async function fetchData() {
try {
Expand Down Expand Up @@ -27,13 +26,13 @@ async function fetchData() {
}

// Render stats
function renderStats(repoStats, contributorsCount) {
function renderStats(repoStats, contributorsCount, totalContributions) {
const statsGrid = document.getElementById('statsGrid');
const stats = [
{ label: 'Contributors', value: contributorsCount, icon: 'users' },
{ label: 'Total Contributions', value: repoStats.contributors?.reduce((sum, contributor) => sum + contributor.contributions, 0) || 0, icon: 'git-commit' },
{ label: 'GitHub Stars', value: repoStats.stargazers_count || 0, icon: 'star' },
{ label: 'Forks', value: repoStats.forks_count || 0, icon: 'git-branch' }
{ label: 'Contributors', value: contributorsCount, icon: 'users' },
{ label: 'Total Contributions', value: totalContributions, icon: 'git-commit' },
{ label: 'GitHub Stars', value: repoStats.stargazers_count || 0, icon: 'star' },
{ label: 'Forks', value: repoStats.forks_count || 0, icon: 'git-branch' }
];

statsGrid.innerHTML = stats.map(stat => `
Expand Down Expand Up @@ -88,7 +87,10 @@ async function init() {

const { contributors, repoStats } = await fetchData();

renderStats(repoStats, contributors.length);
// Calculate total contributions
const totalContributions = contributors.reduce((sum, contributor) => sum + contributor.contributions, 0);

renderStats(repoStats, contributors.length, totalContributions);
renderContributors(contributors);

loading.style.display = 'none';
Expand Down Expand Up @@ -118,4 +120,3 @@ function scrollToContribute() {

// Initialize the page when the DOM is loaded
document.addEventListener('DOMContentLoaded', init);

0 comments on commit f4454c9

Please sign in to comment.