Repository navigation
feat(pricing): 管理员在模型广场看到全站模型 - #259
Merged
Merged
Conversation
Co-Authored-By: Claude Code <[email protected]>
|
Warning Review limit reachedYou'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. View limit details
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. |
|
This pull request is merged. |
clyang82
approved these changes
Nov 23, 2026
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]>
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.
背景
模型广场(
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 测试会超时——既有环境问题)。🤖 Generated with Claude Code