Skip to content

Add per-repo language breakdown badges in TopRepos#294

Closed
Akshat-Neeraj wants to merge 4 commits into
Priyanshu-byte-coder:mainfrom
Akshat-Neeraj:feature-language-breakdown
Closed

Add per-repo language breakdown badges in TopRepos#294
Akshat-Neeraj wants to merge 4 commits into
Priyanshu-byte-coder:mainfrom
Akshat-Neeraj:feature-language-breakdown

Conversation

@Akshat-Neeraj
Copy link
Copy Markdown

Summary

Added language breakdown badges for repositories in TopRepos.

Features

  • Fetches repo language data from GitHub API
  • Displays top 3 languages with percentages
  • Added language color indicators
  • Graceful fallback for failed/empty responses
  • Responsive badge layout

Files Changed

  • src/components/TopRepos.tsx
  • src/app/api/metrics/repos/route.ts

@vercel
Copy link
Copy Markdown

vercel Bot commented May 17, 2026

@Akshat-Neeraj is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Thanks for your first PR on DevTrack! 🎉

A maintainer will review it within 48 hours. While you wait:

  • Make sure CI is passing (type-check + lint)
  • Double-check the PR description is filled out and the issue is linked
  • Feel free to ask questions in Discussions if you need help

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

The language breakdown badges in TopRepos look good, but there's an unintentional import causing the dependency audit to fail:

// src/app/api/metrics/repos/route.ts
import { url } from 'inspector'; // ← Remove this line

inspector is a Node.js debug module — this import is not needed and was likely added accidentally (IDE autocomplete). Remove it and CI should pass.

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

Hi @Akshat-Neeraj — this PR has a merge conflict in TopRepos.tsx (sort and link features have been merged since your branch was created). Please rebase:

git fetch upstream
git rebase upstream/main
# resolve conflicts, keeping your language breakdown badge changes alongside the existing sort/link code
git push --force-with-lease

Once rebased, we'll review and merge.

@Akshat-Neeraj
Copy link
Copy Markdown
Author

Akshat-Neeraj commented May 19, 2026 via email

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

Three issues:

1. Frontend fetches GitHub API without auth token (rate limit)
fetchRepoLanguages in TopRepos.tsx calls https://api.github.com/repos/${repo.name}/languages with no Authorization header. Unauthenticated GitHub API: 60 req/hr limit. With 6 repos × N accounts it depletes quickly.

You already fetch languages server-side in repos/route.ts and return them in the RepoSummary. Remove fetchRepoLanguages from the client entirely — just read repo.languages from the data returned by /api/metrics/repos.

2. Missing cache: "no-store" on new fetch calls
The two new fetches in repos/route.ts (/repos/${name} and /repos/${name}/languages) don't have cache: "no-store". Add it to both, consistent with the rest of the route.

3. mergeRepoCommits loses URL and language data
The merge function now returns { name, commits, url: "" } — the url is always empty string and languages is dropped. Multi-account users will get repos with missing URLs. Fix: when merging, preserve the url and languages from whichever entry has them:

map.set(repo.name, {
  commits: (map.get(repo.name)?.commits ?? 0) + repo.commits,
  url: repo.url || map.get(repo.name)?.url || "",
  languages: repo.languages || map.get(repo.name)?.languages || [],
});

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

  1. Double-fetching languages — API route fetches /repos/{name}/languages server-side AND TopRepos.tsx fires client-side unauthenticated GitHub API calls. The client-side fetch has no auth header (60 req/hr cap). Remove the client-side fetch and use repo.languages from the API response instead. 2. Sort lost in mergeRepoCommits — the .sort() by commits was removed, multi-account users now get unsorted results. Restore it. 3. Indentation — new code blocks inside fetchReposForAccount start at column 0 instead of inside the function body.

@Priyanshu-byte-coder Priyanshu-byte-coder added level:intermediate GSSoC: Intermediate difficulty (35 pts) gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature labels May 20, 2026
Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

Two issues:

  1. Inconsistent indentation — the language badges block in TopRepos.tsx has inconsistent indentation (mix of 15 and 2-space indents inside the list). Please align with the surrounding JSX formatting.

  2. Fallback color'#888' is used as a fallback color for languages. Replace with 'var(--muted-foreground)' to respect the theme.

@Akshat-Neeraj Akshat-Neeraj deleted the feature-language-breakdown branch May 22, 2026 06:38
@Priyanshu-byte-coder Priyanshu-byte-coder added the gssoc:approved GSSoC: PR approved for scoring label May 24, 2026
@Akshat-Neeraj
Copy link
Copy Markdown
Author

Addressed the requested review changes:

  • removed frontend GitHub API fetching
  • added cache handling for GitHub fetches
  • fixed repository merge logic preservation
  • cleaned unused imports
    Build is now passing successfully.
    Thank you for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC: PR approved for scoring gssoc26 GSSoC 2026 contribution level:intermediate GSSoC: Intermediate difficulty (35 pts) type:feature GSSoC type bonus: new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants