Skip to content

Final fix for stats cards: robust data fetching and complete features#9

Merged
Chintanpatel24 merged 1 commit into
mainfrom
feat-and-fix-cards-9021963555964763502
May 14, 2026
Merged

Final fix for stats cards: robust data fetching and complete features#9
Chintanpatel24 merged 1 commit into
mainfrom
feat-and-fix-cards-9021963555964763502

Conversation

@Chintanpatel24
Copy link
Copy Markdown
Owner

  • Resolved Issue Enhancement for the PR card #3: Enhanced PR summary card layout (Merged, Total, Open).
  • Resolved Issue A new card is wanted for the gitlyy !! #4: Implemented Issue card with requested layout (Open, Total, Closed) and red accent.
  • Resolved Issue mastercard SVG #5: Fully implemented Mastercard (Dashboard) with aggregated stats.
  • Resolved Issue [issue]: Workflow run fails. #6: Added Node.js CI workflow and package-lock.json.
  • Robustness: Refactored src/github.js with safeFetch, timeouts, and better error handling to prevent broken images.
  • Documentation: Updated README.md and public/index.html with new cards and examples.
  • Corrected totalCommits handling in Mastercard.

- Resolved Issue #3: Enhanced PR summary card layout (Merged, Total, Open).
- Resolved Issue #4: Implemented Issue card with requested layout (Open, Total, Closed) and red accent.
- Resolved Issue #5: Fully implemented Mastercard (Dashboard) with aggregated stats.
- Resolved Issue #6: Added Node.js CI workflow and package-lock.json.
- Robustness: Refactored src/github.js with safeFetch, timeouts, and better error handling to prevent broken images.
- Documentation: Updated README.md and public/index.html with new cards and examples.
- Corrected totalCommits handling in Mastercard.

Co-authored-by: Chintanpatel24 <216989679+Chintanpatel24@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 14, 2026 16:41
@Chintanpatel24 Chintanpatel24 merged commit 9f9b4b3 into main May 14, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors GitHub data-fetching helpers to make the stats-card APIs more resilient and to support PR, issue, overview, language, streak, and master-card metrics.

Changes:

  • Adds a shared safeFetch wrapper with timeout/error handling.
  • Updates PR, issue, profile, commit, star, and language fetchers to use safer fallbacks.
  • Adjusts pagination and aggregation behavior for PRs, repositories, and languages.
Comments suppressed due to low confidence (2)

src/github.js:264

  • Capping repository pagination at five pages silently ignores repositories after the first 500. fetchUserTotalStars is used for the overview card's total stars, so users with more than 500 owned repositories will get an undercounted total.
  while (page <= 5) {
    const url = `${GITHUB_API}/users/${encodeURIComponent(username)}/repos?type=owner&per_page=100&page=${page}`;
    const data = await safeFetch(url);
    if (!data || !Array.isArray(data) || data.length === 0) break;

src/github.js:400

  • The activity-by-language calculation only fetches language data for the first 20 eligible repositories on each page, excluding the remaining repos from totalActivity and percentages. This makes the mode=commits language card materially inaccurate for users with many repositories.
    const promises = repos
      .filter((r) => !r.fork && r.size > 0)
      .slice(0, 20)
      .map(async (repo) => {
        const langs = await safeFetch(repo.languages_url);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/github.js
Comment on lines 27 to +29
if (!res.ok) {
throw new Error(`GitHub API error: ${res.status} ${res.statusText}`);
console.warn(`GitHub API warning: ${res.status} for ${url}`);
return null;
Comment thread src/github.js
Comment on lines +47 to +53
while (page <= 5) {
const url = `${GITHUB_API}/search/issues?q=author:${encodeURIComponent(username)}+type:pr&per_page=${perPage}&page=${page}`;
const data = await safeFetch(url);
if (!data || !data.items || data.items.length === 0) break;

allPRs = allPRs.concat(data.items);
if (allPRs.length >= data.total_count || data.items.length < perPage) break;
Comment thread src/github.js
Comment on lines +132 to +137
const res = await fetch(url, {
headers: {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
Accept: "text/html",
},
});
Comment thread src/github.js
const promises = repos
.filter((r) => !r.fork && r.size > 0)
.slice(0, 30) // limit to 30 repos to avoid rate limits
.slice(0, 20)
Comment thread src/github.js
if (!res.ok) break;
const repos = await res.json();
if (!repos.length) break;
while (page <= 3) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants