Skip to content

feat(leaderboard): follower leaderboard ranked by streak/commits/PRs (Issue #79)#2764

Open
Ridanshi wants to merge 7 commits into
Priyanshu-byte-coder:mainfrom
Ridanshi:feat/follower-leaderboard-79
Open

feat(leaderboard): follower leaderboard ranked by streak/commits/PRs (Issue #79)#2764
Ridanshi wants to merge 7 commits into
Priyanshu-byte-coder:mainfrom
Ridanshi:feat/follower-leaderboard-79

Conversation

@Ridanshi

Copy link
Copy Markdown
Contributor

Summary

  • Implements GET /api/leaderboard/followers — authenticated endpoint returning the user's GitHub followers ranked by streak, commits this month, or merged PRs
  • Adds src/lib/follower-leaderboard.ts with 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 limits
  • Adds FollowerLeaderboard client component with loading skeletons, empty state, sort toggle (streak / commits / PRs), error handling, and retry flow
  • Adds /dashboard/followers page with auth guard and Suspense boundary

Test plan

  • 66 unit/integration tests pass (test/follower-leaderboard.test.ts, test/follower-leaderboard-route.test.ts, test/FollowerLeaderboard.test.tsx)
  • TypeScript typecheck passes (npx tsc --noEmit)
  • ESLint passes on all changed files
  • next build succeeds — /dashboard/followers route included in output

Closes #79

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature type:testing GSSoC type bonus: tests (+10 pts) type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:performance GSSoC type bonus: performance (+15 pts) labels Jun 23, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Umbrella-io — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Ridanshi and others added 6 commits June 24, 2026 01:15
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
@Ridanshi Ridanshi force-pushed the feat/follower-leaderboard-79 branch from 42d43ea to cebf0f2 Compare June 24, 2026 11:13
@Priyanshu-byte-coder

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Follower leaderboard — rank GitHub followers by streak and commits

2 participants