Skip to content

feat(pricing): 管理员在模型广场看到全站模型 - #259

Merged
mergify[bot] merged 1 commit into
suanova:mainfrom
skeeey:feat/pricing-admin-full-view
Nov 23, 2026
Merged

mergify[bot] merged 1 commit into
suanova:mainfrom
skeeey:feat/pricing-admin-full-view

Conversation

@skeeey

@skeeey skeeey commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

背景

模型广场(GET /api/pricing)此前对所有访问者都按账号可用分组过滤:root/admin 在 default 组时也只能看到自己可用分组里的模型,无法在价目页核对其它分组配置了什么。历史上 #178 里有一版管理员全量视图,随后随 Model Square 的其它改动被整体回退,未进入 main。

本次按方案 A 重新落地:管理员始终看全站,不加 全部 / 我的分组 开关。

改动

  • controller/pricing.go:新增 collectPricingGroups(pricing),汇总价目表里出现过的全部业务分组(跳过 "" 与 all,描述沿用 setting.GetUsableGroupDescription,未配置时回退分组名)。
  • GetPricing 增加 role >= RoleAdminUser 分支:跳过分组过滤,usable_group 使用全量分组;普通用户/匿名仍走 GetAccountUsableGroups + filterPricingByUsableGroups。
  • 组织成员白名单、group_ratio 末尾裁剪、模型折扣与响应字段保持不变;前端零改动(侧边栏分组筛选直接读 usable_group)。
  • 行为说明:管理员在组织上下文仍看全站(角色优先);管理员账号自身的 GroupGroupRatio 特例继续折叠进 group_ratio(沿用现有计算顺序)。models.status != 1 与没有任何启用渠道的模型仍不会进入价目表(属于「模型管理」页)。

测试

  • 新增 controller/pricing_admin_view_test.go:
    • TestCollectPricingGroupsExpandsAdminView:all/空串不进集合、描述回退、空价目表返回空集合。
    • TestGetPricingAdminSeesAllSiteGroups:管理员看到四个分组的模型与全部分组;普通用户/匿名仍只看到 default/vip;yeebo-group 倍率保留、no-ratio-group 只出现在 usable_group。
    • TestGetPricingAdminInOrganizationContextSeesAllSiteGroups:组织上下文下管理员仍是全站视图。
    • TestGetPricingAdminViewDoesNotPollutePricingCache:请求前后 model.GetPricing() 一致。
  • go build ./...;go test ./controller -run 'Pricing|GetPricing' -race 通过(含既有成员白名单/折扣/组织上下文用例)。
  • 仓库全量 go test $(go list ./... | grep -v /main$) -race 通过(本机 WSL 需先在 127.0.0.1:1 起 accept-close 监听器,否则 controller 插件 loop 测试会超时——既有环境问题)。
  • 本次无 schema/SQL 变更,未涉及三库矩阵。

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3d12839 and 4192391.

Files selected for processing: 2

  • controller/pricing.go
  • controller/pricing_admin_view_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@mergify

mergify Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

This pull request is merged.

@mergify
mergify Bot merged commit 3a55a1a into suanova:main Nov 23, 2026
8 checks passed
mergify Bot pushed a commit that referenced this pull request Nov 27, 2026
- 2026-11-23-pricing-admin-full-view-design.md(已由 #259 实现)
- 2026-11-24-admin-all-users-api-keys-design.md(已由 #267 实现)

Co-authored-by: Wei Liu <[email protected]>
Co-authored-by: Claude Code <[email protected]>
@skeeey
skeeey deleted the feat/pricing-admin-full-view branch December 1, 2026 07:42
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.

2 participants