Repository navigation
fix(ui): gateway-wide totals on /apps and /enterprise - #2212
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThe PR refactors the public apps API to fetch aggregate totals via parallel queries and return precomputed summaries. The Enterprise page is converted to async to server-side fetch these totals with ISR caching, then passes them to the Hero component, which formats and displays them as ticker statistics using a new helper function. ChangesEnterprise Stats Server-Side Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The
/appsheadline stats and/enterprisehero stats were showing dramatically smaller numbers than the admin Global Stats widget (e.g. 7.51B vs 127B tokens). Two reasons:/public/appsendpoint excludessource = 'unknown'(untagged traffic, the vast majority of requests), andapps.reduce(...)), capped atlimit=200.This PR keeps the leaderboard scoped to known apps but makes the headline numbers reflect gateway-wide all-time traffic, matching admin.
Changes
apps/api/src/routes/public-apps.ts: split into two queries — leaderboard rows (excludesunknown, capped bylimit) + a separate aggregate over allglobalSourceStatsrows fortotalTokens/totalRequests.totalAppsis nowCOUNT(DISTINCT source) FILTER (source <> 'unknown'), no longer capped bylimit.apps/ui/src/components/enterprise/hero.tsx: hero now accepts optionaltotalTokens/totalRequestsprops and converts them to ticker-friendly value+suffix. "Daily Tokens" and "Customer Savings" stay hardcoded.apps/ui/src/app/enterprise/page.tsx: server-fetches/public/apps(withlimit=1, since it only consumes the totals) and passes them into the hero.revalidate = 300.Test plan
/apps— "tokens processed" and "requests routed" should match admin Global Stats; leaderboard list still excludesunknown./enterprise— hero "Total Tokens Processed" and "Total Requests" stat cards reflect live gateway totals (with hardcoded fallback if fetch fails).pnpm buildpasses.🤖 Generated with Claude Code
Summary by CodeRabbit