Leaderboard migration#1907
Conversation
|
@SamXop123 is attempting to deploy a commit to the recode Team on Vercel. A member of the Team first needs to authorize it. |
|
Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. The estimated time for response is 5–8 hrs. In the meantime, please provide all necessary screenshots and make sure you run - npm build run , command and provide a screenshot, a video recording, or an image of the update you made below, which helps speed up the review and assignment. If you have questions, reach out to LinkedIn. Your contributions are highly appreciated!😊 Note: I maintain the repo issue every day twice at 8:00 AM IST and 9:00 PM IST. If your PR goes stale for more than one day, you can tag and comment on this same issue by tagging @sanjay-kv. We are here to help you on this journey of open source. Consistent 20 contributions are eligible for sponsorship 💰 🎁 check our list of amazing people we sponsored so far: GitHub Sponsorship. ✨ 📚Your perks for contribution to this community 👇🏻
If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊 |
|
✅ Synchronized metadata from Issue #1362:
|
The
|
|
@iitzIrFan this was a multiple repo issue as suggested by @Adez017 so i had to create two pr for backend migration |
|
Okay makes scenes now, @Adez017 will review soon! |
will review it in the morning @iitzIrFan , need to take a look closer onwards |
|
it works perfectly fine on local testing. just needs a few production tests a little help for reviewers for production tsting:
|
There was a problem hiding this comment.
Pull request overview
This PR migrates the website’s leaderboard/community stats data flow away from client-side GitHub scraping toward a dedicated backend API, aligning with the goal of reducing GitHub rate-limit pressure and improving page-load responsiveness.
Changes:
- Added a
backendApiUrlDocusauruscustomFieldsvalue for configuring the backend base URL. - Updated
CommunityStatsProviderto fetch/api/leaderboardand/api/statsfrom the backend in parallel instead of scraping GitHub on the client. - Removed now-obsolete organization stats scraping methods from
GitHubService.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| docusaurus.config.ts | Adds backendApiUrl to browser-exposed config; (still) exposes gitToken via customFields. |
| src/lib/statsProvider.tsx | Replaces client-side scraping pipeline with backend fetch + mapping into existing context state. |
| src/services/githubService.ts | Removes org stats scraping/aggregation methods that are no longer used by the frontend. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const token = customFields?.gitToken || ""; | ||
| const backendApiUrl = (customFields?.backendApiUrl as string) || "http://localhost:5000"; |
| data: { | ||
| contributors: contributorsArray, | ||
| rawStats: { totalPRs: totalMergedPRs }, | ||
| rawStats: { totalPRs: statsData.totalContributors }, | ||
| }, |
There was a problem hiding this comment.
@Adez017 I need your review on merged PR
https://github.com/recodehive/leaderboard/pull/1/changes
This is the backend code.
| backendApiUrl: process.env.BACKEND_API_URL || "http://localhost:5000", | ||
| gitToken: process.env.DOCUSAURUS_GIT_TOKEN, | ||
| clerkPublishableKey: process.env.VITE_CLERK_PUBLISHABLE_KEY || "", |
There was a problem hiding this comment.
I think now we don't need to mount the git token , let me know if it is required or we can move forward and remove this one @SamXop123
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
✅ Synchronized metadata from Issue #1362:
|

Whats implemented:
"recode"label, aggregates repository statistics, and counts discussions.leaderboard.jsonandstats.jsoninside the cache directory (compatible with persistent volume mounts)./api/leaderboardand/api/stats.CommunityStatsProvider) fetches from these two backend API routes in parallel on page load. Client-side sorting and date filtering (week/month/year/all-time) are preserved in memory for instant, responsive UI transitions.Files Changed:
Backend (leaderboard repository)
server.js: Setup API routes, CORS configs, and initialized startup checks.utils/cacheHelper.js[NEW]: Implements atomic file writes (writeJsonAtomic) to prevent corruption, file exists checks, and fallback JSON models.functions/generateLeaderboard.js: Replaced legacy scraper. Implements GraphQL repository traversal, label scoring weight filters, active streak checks, and discussions count queries.functions/generateCALeaderboard.js: Integrates atomic writes and generation locks.jobs/updateOSLeaderboard.js: Schedules OS leaderboard cron jobs.jobs/updateCALeaderboard.js: Standardizes cron patterns.Frontend (this repository)
docusaurus.config.ts: DeclaresbackendApiUrlcustomField and removes deprecatedgitTokenclient exposing.src/lib/statsProvider.tsx: Removes client-side scraping pipelines. Fetches and parses backend API endpoints and binds to context states.src/services/githubService.ts: Removes dead code path helper methods.API Contract
A.
GET /api/leaderboardReturns the contributors array and legacy compatibility aliases.
{ "success": true, "updatedAt": 1781548394726, "lastUpdated": 1781548394726, "generated": true, "contributors": [ { "username": "contributor1", "avatar": "https://github.com/contributor1.png", "profile": "https://github.com/contributor1", "points": 60, "prs": 2, "prDetails": [ { "title": "PR 2 - Docs", "url": "https://github.com/recodehive/repo1/pull/2", "mergedAt": "2026-06-15T12:00:00Z", "repoName": "repo1", "number": 2, "points": 50 } ], "streak": 2 } ] }B.
GET /api/stats{ "success": true, "updatedAt": 1781548394731, "lastUpdated": 1781548394731, "totalStars": 984, "totalForks": 1107, "totalContributors": 467, "totalRepositories": 10, "publicRepositories": 9, "discussionsCount": 42 }Migration Strategy
CACHE_DIRto a persistent volume (e.g./data) to preserve cached listings across restarts. SetPORT(default5000) and the privateGIT_TOKEN.BACKEND_API_URLpointing to the deployed backend server domain.Testing Performed
Fixes #1362
Type of Change
Checklist
npm run buildand attached screenshot(s) in this PR.