fix(repo): paginate user repositories in repo explorer#3219
fix(repo): paginate user repositories in repo explorer#3219desireddymohithreddy0925 wants to merge 3 commits into
Conversation
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
|
Closer, thanks for splitting it out — but this is backend-only and would regress the explorer. The consumer |
Summary
This PR implements server-side pagination for the Repo Explorer. It cleanly separates the pagination functionality from the unrelated milestone/goal-category changes that caused conflicts in previous PR attempts, ensuring the UI remains fast for users with large numbers of repositories.
Closes #3136
Type of Change
What Changed
src/lib/github.ts: Introduced a newfetchUserReposPaginatedfunction andPaginatedReposResultinterface to selectively fetch a specific page of repositories and extract thehasNextPageboolean from GitHub'sLinkheader. This avoids altering the originalfetchUserReposreturn signature, preserving compatibility across other endpoints.src/app/api/metrics/repo-explorer/route.ts: Updated the endpoint to extractpageandper_pagequery parameters. Replaced the heavy, multi-page data fetch withfetchUserReposPaginated, injecting the parameters into the cache key to accurately serve paginated chunks. The endpoint now returns{ repos, hasNextPage }.test/github.test.ts: Added validation for the newPaginatedReposResultinterface.How to Test
?page=2to the API request or utilizing the UI's pagination control).hasNextPageaccurately reflects the presence of remaining repositories.Expected result: The Repo Explorer should load instantly rather than waiting for up to 10 sequential API calls, and cleanly transition between pages without duplicate renders or missing commits.
Checklist
console.log, debug code, or commented-out blocksnpm run lintpasses locallynpm run type-check)Accessibility (UI changes only)
Additional Context
This is a focused, rebased follow-up to the previously cluttered PRs (#2903 and #3135) to implement the required API modifications securely and smoothly, ensuring a completely green build without conflicts.