Migrate Leaderboard & Stats Scraping to Backend API Cache#1
Conversation
|
maintainers please verify whether all the api contracts are fine or not. and also i tested this using a custom leaderboard test file, which worked completely fine. just a test on an actual production env is needed recode-website pr : recodehive/recode-website#1907 |
Adez017
left a comment
There was a problem hiding this comment.
rest othe things looks fine to me @sanjay-kv
| app.get("/", (req, res) => { | ||
| res.send("Hello World"); | ||
| }); | ||
|
|
There was a problem hiding this comment.
I don't think we need to return hello world somewhere
@SamXop123 can you refer the file in which the implementation details are and one more thing we can drill down to |
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 (this 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 (
recode-websiterepository)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