Skip to content

feat(classic): add rankings page with model and vendor leaderboards - #5404

Closed
MetaInsight7 wants to merge 1 commit into
QuantumNous:mainfrom
MetaInsight7:fe_dev/add_ranking
Closed

MetaInsight7 wants to merge 1 commit into
QuantumNous:mainfrom
MetaInsight7:fe_dev/add_ranking

Conversation

@MetaInsight7

@MetaInsight7 MetaInsight7 commented Jun 9, 2026 •

Copy link
Copy Markdown

Add complete rankings feature to web/classic including:

  • Rankings page with period tabs (today/week/month/year/all)
  • ModelsSection with VChart history chart and ranked model list
  • MarketShareSection with vendor share chart and color-coded list
  • PulseSection showing trending up/down models
  • Navigation integration and admin settings for rankings module

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

(请在此粘贴截图、关键日志或测试报告,以证明变更生效)

Summary by CodeRabbit

  • New Features
    • Added a new Rankings page with period filtering (today, week, month, year, all-time).
    • Added Models rankings display showing token usage and growth trends.
    • Added Market share section with vendor comparisons and stacked bar charts.
    • Added Pulse section highlighting top market movers and droppers.
    • Added Rankings module to navigation with configurable visibility and optional authentication.

Add complete rankings feature to web/classic including:
- Rankings page with period tabs (today/week/month/year/all)
- ModelsSection with VChart history chart and ranked model list
- MarketShareSection with vendor share chart and color-coded list
- PulseSection showing trending up/down models
- Navigation integration and admin settings for rankings module

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: abbaf2ae-cab1-4f9d-bd6e-f27186349462

📥 Commits

Reviewing files that changed from the base of the PR and between d2576dd and c8c1d0b.

📒 Files selected for processing (13)
  • web/classic/src/App.jsx
  • web/classic/src/components/layout/PageLayout.jsx
  • web/classic/src/components/rankings/GrowthText.jsx
  • web/classic/src/components/rankings/MarketShareSection.jsx
  • web/classic/src/components/rankings/ModelsSection.jsx
  • web/classic/src/components/rankings/PulseSection.jsx
  • web/classic/src/components/rankings/index.jsx
  • web/classic/src/helpers/lobeIcon.jsx
  • web/classic/src/helpers/rankings.js
  • web/classic/src/hooks/common/useNavigation.js
  • web/classic/src/hooks/rankings/useRankingsData.js
  • web/classic/src/pages/Rankings/index.jsx
  • web/classic/src/pages/Setting/Operation/SettingsHeaderNavModules.jsx

Walkthrough

This PR introduces a new Rankings feature page showing model and market-share rankings with period-based filtering (today/week/month/year/all). The feature includes lazy-loaded page routing with optional auth protection, data fetching from /api/rankings, three ranking display sections with stacked bar charts, utility formatters for tokens and percentages, and full navigation/settings integration for feature gating.

Changes

Rankings Page Feature

Layer / File(s) Summary
Formatting and Icon Utilities
web/classic/src/helpers/rankings.js, web/classic/src/helpers/lobeIcon.jsx, web/classic/src/components/rankings/GrowthText.jsx
Added formatTokens (K/M/B magnitude formatting), formatShare (percentage formatting), getLobeIcon (dynamic icon component resolution from @lobehub/icons with encoded props), and GrowthText percentage-growth indicator component with arrow/color coding.
Rankings Data Fetching Hook
web/classic/src/hooks/rankings/useRankingsData.js
Implemented useRankingsData hook that manages period state, fetches from /api/rankings, validates period against whitelist, and exposes { period, changePeriod, snapshot, loading, error }.
Rankings Page and Section Components
web/classic/src/pages/Rankings/index.jsx, web/classic/src/components/rankings/index.jsx, web/classic/src/components/rankings/ModelsSection.jsx, web/classic/src/components/rankings/MarketShareSection.jsx, web/classic/src/components/rankings/PulseSection.jsx
Added RankingsPage orchestrator with period-switching tabs, ModelsSection (stacked bar chart + model rankings list), MarketShareSection (vendor market-share chart + vendor rankings list), and PulseSection (top movers/droppers cards). Sections use memoized data ordering, vendor-color mapping, chart tooltip aggregation, and growth percentage rendering.
Route Wiring and Auth Protection
web/classic/src/App.jsx, web/classic/src/components/layout/PageLayout.jsx
Lazy-loaded Rankings page component, added rankingsRequireAuth memoization that parses status.HeaderNavModules JSON with backward-compatible boolean handling, wrapped /rankings route in conditional PrivateRoute based on auth requirement, and added /rankings to fixed-layout routes in PageLayout.
Navigation and Settings Integration
web/classic/src/hooks/common/useNavigation.js, web/classic/src/pages/Setting/Operation/SettingsHeaderNavModules.jsx
Added rankings to default navigation modules and mainNavLinks with "排行榜" label; extended navigation filtering to support object-form rankings config with enabled property; added rankings module card in settings UI with requireAuth sub-configuration toggle; implemented backward-compatible parsing of boolean/missing rankings into { enabled, requireAuth: false } shape in persisted options; added dedicated handleRankingsAuthChange handler.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant RankingsPage
  participant useRankingsData
  participant API
  participant ModelsSection
  participant MarketShareSection
  participant PulseSection
  User->>RankingsPage: Navigate to /rankings
  RankingsPage->>useRankingsData: call hook with default 'week' period
  useRankingsData->>API: GET /api/rankings?period=week
  API-->>useRankingsData: { models, vendors, movers, droppers }
  useRankingsData-->>RankingsPage: snapshot ready
  RankingsPage->>ModelsSection: pass models history and rows
  RankingsPage->>MarketShareSection: pass vendor history and rows
  RankingsPage->>PulseSection: pass movers and droppers
  ModelsSection-->>RankingsPage: render chart and list
  MarketShareSection-->>RankingsPage: render chart and list
  PulseSection-->>RankingsPage: render mover cards
  RankingsPage-->>User: display rankings UI
  User->>RankingsPage: click different period tab
  RankingsPage->>useRankingsData: call changePeriod
  useRankingsData->>API: GET /api/rankings?period=month
  API-->>useRankingsData: updated snapshot
  useRankingsData-->>RankingsPage: refresh components
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • QuantumNous/new-api#5232: Both PRs extend PageLayout's fixed-layout route-condition logic to include new routes alongside existing /console/* and /pricing.
  • QuantumNous/new-api#4802: Both PRs implement rankings feature-gating via HeaderNavModules config parsing with enabled/requireAuth boolean/object handling on the frontend routing layer.
  • QuantumNous/new-api#1701: Main PR's rankings module configuration is managed through status.HeaderNavModules, which is the header-navigation surface introduced and managed by PR #1701.

Suggested reviewers

  • Calcium-Ion
  • creamlike1024

Poem

🐰 A rankings page hops into view,
Charts and movers in vibrant hue,
With icons fetched and tokens formatted just right,
The feature gates softly, auth shining bright! ✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MetaInsight7
MetaInsight7 deleted the fe_dev/add_ranking branch June 9, 2026 17:15
@MetaInsight7
MetaInsight7 restored the fe_dev/add_ranking branch June 9, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant