Conversation
|
@caiodomingues is attempting to deploy a commit to the isabellaherman's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
This PR re-enables the auto-sync feature for XP data that was previously disabled due to excessive GitHub API requests (~400k/hour). It introduces a 3-layer safeguard system: client-side localStorage-based cooldown (30 min), server-side database cooldown (5 min), and GitHub rate limit pre-check (skip if <50 remaining). It also replaces the page reload approach with in-place leaderboard refresh and adds cross-tab sync deduplication via BroadcastChannel.
Changes:
- Added rate limit pre-check in
syncUserDatato skip syncs when GitHub API quota is low - Added server-side cooldown in the force-sync API route to return cached data when the last update was less than 5 minutes ago
- Replaced the commented-out auto-sync with a properly guarded implementation using client-side cooldown, cross-tab deduplication, and in-place leaderboard refresh
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lib/xp-calculator.ts |
Adds GitHub rate limit pre-check before performing sync API calls |
app/api/force-sync/route.ts |
Adds server-side 5-minute cooldown using lastXpUpdate field |
app/page.tsx |
Replaces disabled auto-sync with guarded implementation (30-min client cooldown, BroadcastChannel cross-tab dedup, in-place leaderboard refresh) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
rate limit pre-check (<50 remaining → skip)
window.location.reload()with in-place leaderboard refreshBroadcastChannelto prevent duplicate syncs across browser tabs