feat(leaderboard): follower leaderboard ranked by streak/commits/PRs (Issue #79)#2764
Open
Ridanshi wants to merge 7 commits into
Open
feat(leaderboard): follower leaderboard ranked by streak/commits/PRs (Issue #79)#2764Ridanshi wants to merge 7 commits into
Ridanshi wants to merge 7 commits into
Conversation
GSSoC Label Checklist 🏷️@Umbrella-io — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
Implements GET /api/leaderboard/followers with:
- GitHub follower fetch (max 20), concurrent stat aggregation (5 at a time)
- Streak from public PushEvents, commits/PRs via GitHub Search API
- Sort by streak (default), commits, or PRs; stable tie-breaking
- 5-minute cache (leaderboard:followers:v1:{login}); re-sort from cache
- In-memory + Upstash rate limit: 10 req / 30 s per user
- GitHubRateLimitError → 503 with Retry-After header
Frontend: /dashboard/followers page with FollowerLeaderboard component
- Responsive table, loading skeleton, empty state, error+rate-limit state
- Sort toggle buttons with aria-pressed; accessible columnheader roles
Fixes TS2339 in settings route (user_widget_prefs missing from body type)
Tests: 66 passing across follower-leaderboard, route, and component suites
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add user_widget_prefs JSONB column via Supabase migration - Implement mergeWidgetPrefs/validateWidgetPrefs utility with fallback-to-visible defaults - Extend settings API (GET/PATCH) with tiered schema compatibility for user_widget_prefs - Add Dashboard Widgets section to settings page with toggle per widget and save button - CustomizableDashboard fetches prefs on mount and filters widgets by visibility - New widgets absent from stored JSON default to visible - 27 tests covering merge logic, validation, API contract, and edge cases
…tency - Replace in-memory delivery dedup with webhook_deliveries DB table; 23505 conflict on insert short-circuits duplicate GitHub deliveries across serverless restarts - Call increment_goal_progress RPC on each push event to atomically increment eligible commit goals without exceeding their target ceiling - Add monthly goal support to POST /api/goals/sync alongside existing weekly sync; goalDateRange selects the correct period per recurrence - Extract syncGoals reconciliation service to src/lib/github/syncGoals.ts with isGoalInCurrentPeriod for period-eligibility filtering - Add supabase migration creating webhook_deliveries table and increment_goal_progress SQL function (LEAST-based ceiling, SECURITY DEFINER) - Add 29-test suite covering period helpers, idempotency invariants, ceiling semantics, response shape, eligibility filtering, and rate-limit propagation - Update webhook-response-shape mock to cover insert and rpc chains
…iyanshu-byte-coder#97) Implements a complete badge system with 8 badges: Week Warrior, Month Master, Century, Night Owl, Early Bird, PR Machine, Star Collector, Ice Saver. - src/lib/badges.ts: centralized BADGE_DEFINITIONS, BadgeStats interface, computeEarnedBadgeKeys() and computeBadgeProgress() pure functions - src/app/api/badges/route.ts: GET /api/badges gathers GitHub stats concurrently, syncs earned badges to user_badges table (idempotent), returns {earned, locked} with progress and tooltips - src/app/api/public/[username]/badges/route.ts: public endpoint returning earned badges by username for profile pages - src/components/AchievementBadges.tsx: dashboard widget with earned/locked grid, progress bars, hover tooltips, loading skeleton, empty state - src/lib/dashboard-layout.ts: added "devtrack-badges" widget to goals section - src/components/dashboard/CustomizableDashboard.tsx: renders badge widget - src/app/u/[username]/page.tsx: displays earned badges on public profile - src/lib/metrics-cache.ts: adds badge-specific cache TTL keys - test/badges.test.ts: 38 tests covering computation, progress, idempotency, API auth, response shape, edge cases (threshold boundaries, multi-badge) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…s (Issue Priyanshu-byte-coder#177) Implements public /org/[orgName] page and /api/public/org/[orgName] API with commit totals, streak/commit/PR leaderboards, paginated member table, 1-hour caching, rate-limit protection, skeleton loaders, and 29 unit tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Install @anthropic-ai/sdk and fix vitest 4.x mock constructor compatibility (vi.fn() no longer allows arrow functions as constructors) - Add isSupabaseAdminAvailable to supabase mocks in repos and token tests - Add 502 error handling around getAccountToken and account lookup in repos route - Fix org: parameter parsing in contributions route — extract orgName from parts[1], validate empty org returns 400, reset targetAccountId to null so session user's own account is used for the GitHub query - Use consistent sync error message (msg variable) in GoalTracker - Add vi.clearAllMocks() to follower-leaderboard cache integration beforeEach to prevent call-count bleed between tests - Update user-settings-api tests to include user_widget_prefs in expected responses - Fix useUserSettings refetch test expectation for single-mount fetch behavior - Mock next-intl/plugin and next-pwa in security-headers test to avoid webpack dependency in test environment - Update github-orgs mock to support double .eq() chaining for getAccountToken
42d43ea to
cebf0f2
Compare
Owner
|
Thanks for the contribution! We are currently in a code cleanup sprint and not accepting new features. Please see the discussion for details: #2651 This PR will be revisited once the sprint ends. In the meantime, contributions to testing, refactoring, bug fixes, or documentation are welcome. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /api/leaderboard/followers— authenticated endpoint returning the user's GitHub followers ranked by streak, commits this month, or merged PRssrc/lib/follower-leaderboard.tswith deterministic ranking, in-memory/Upstash caching (5 min TTL), concurrency-limited GitHub data fetching (20 follower cap), and graceful handling of private/deleted users and rate limitsFollowerLeaderboardclient component with loading skeletons, empty state, sort toggle (streak / commits / PRs), error handling, and retry flow/dashboard/followerspage with auth guard and Suspense boundaryTest plan
test/follower-leaderboard.test.ts,test/follower-leaderboard-route.test.ts,test/FollowerLeaderboard.test.tsx)npx tsc --noEmit)next buildsucceeds —/dashboard/followersroute included in outputCloses #79