Fix achievement rate limit#2297
Conversation
…limit # Conflicts: # src/app/api/metrics/achievement-progress/route.ts # src/lib/metrics-cache.ts
|
@VIDYANKSHINI 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. |
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates caching and formatting for the achievement-progress metrics endpoint.
Changes:
- Increased
achievement-progresscache TTL from 10 minutes to 2 hours. - Removed an invisible BOM/odd leading character from the
achievement-progressAPI route import line.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/lib/metrics-cache.ts | Adjusts cache TTL value for achievement-progress. |
| src/app/api/metrics/achievement-progress/route.ts | Normalizes file start/import line by removing BOM/leading character. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| compare: 30 * 60, | ||
| "weekly-summary": 30 * 60, | ||
| "commit-times": 30 * 60, | ||
| "achievement-progress": 10 * 60, | ||
| "achievement-progress": 7200, | ||
| } as const; |
Summary
This PR resolves the GitHub Search API rate limit exhaustion bug by wrapping the
/api/metrics/achievement-progressroute with our Redis/Memory caching layer. The achievement progress estimator now relies on cached data instead of making a live API call on every dashboard load.Closes #2296
Type of Change
What Changed
src/lib/metrics-cache.ts: Added"achievement-progress"to theMETRICS_CACHE_TTL_SECONDSmap with a TTL of 7200 seconds (2 hours) to avoid repetitive external fetches for non-realtime historical achievements.src/app/api/metrics/achievement-progress/route.ts: Refactored the route handler to pass the achievement progress fetch operation throughwithMetricsCache(), assigning a specific cache key using theuser.id.How to Test
npm installfollowed bynpm run dev.AchievementProgressTrackerwidget is rendered./search/commitsor GraphQL API is not being spammed, and rate limits are not triggered.Expected result: The achievement estimator fetches the data once and then accurately serves subsequent requests directly from the local memory / Redis cache.
Screenshots / Recordings
N/A (No visual UI changes, only backend fetching logic optimizations)
Checklist
console.log, debug code, or commented-out blocksnpm run lintpasses locallynpm run type-check)Accessibility (UI changes only)
N/A
Additional Context
The caching mechanism honors the standard
?refresh=true/?bypassCache=truebypass flags. If a developer explicitly needs to re-sync achievements, they can still trigger a bypass to query the fresh data.