Skip to content

Commit

Permalink
Update contributor.js
Browse files Browse the repository at this point in the history
  • Loading branch information
NidhiTornekar authored Jul 9, 2024
1 parent e02494b commit a5a38d0
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions assets/js_files/contributor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,28 @@ async function fetchContributors(pageNumber) {
if (!response.ok) {
throw new Error(`Failed to fetch contributors data. Status code: ${response.status}`);
}

const contributorsData = await response.json();
return contributorsData;
}

// Function to fetch all contributors
async function fetchAllContributors() {
let allContributors = [];
let pageNumber = 1;

try {
while (true) {
const contributorsData = await fetchContributors(pageNumber);
if (contributorsData.length === 0) {
break;
}
let pageNumber = 1;
let allContributors = [];
let contributorsData;

do {
contributorsData = await fetchContributors(pageNumber);
allContributors = allContributors.concat(contributorsData);
pageNumber++;
}
allContributors.forEach((contributor) => {
if (contributor.login === owner) {
return;
} while (contributorsData.length > 0);

for (const contributor of allContributors) {
if(contributor.login === owner){
continue;
}
const userDetailsResponse = await fetch(contributor.url);
const userDetails = await userDetailsResponse.json();

const contributorCard = document.createElement('div');
contributorCard.classList.add('contributor-card');
Expand All @@ -45,16 +44,16 @@ async function fetchAllContributors() {
loginLink.href = contributor.html_url;
loginLink.target = '_blank';
loginLink.appendChild(avatarImg);

const nameOverlay = document.createElement('div');
nameOverlay.classList.add('name-overlay');
nameOverlay.textContent = contributor.login;
nameOverlay.textContent = userDetails.name || contributor.login;

contributorCard.appendChild(loginLink);
contributorCard.appendChild(nameOverlay);

cont.appendChild(contributorCard);
});
}
} catch (error) {
console.error(error);
}
Expand Down

0 comments on commit a5a38d0

Please sign in to comment.