[codex] feat(logs): filter model test logs in admin view - #6314
[codex] feat(logs): filter model test logs in admin view#6314IQZZ020501 wants to merge 3 commits into
Conversation
…n user role - Created project function and design documentation in `docs/project/README.md`, `docs/project/architecture.md`, `docs/project/billing-and-data.md`, `docs/project/development-guide.md`, `docs/project/frontend-design.md`, `docs/project/relay-pipeline.md`, and `docs/project/features.md`. - Implemented a `.gitignore` file for CodeGraph data files. - Updated `SiderBar.jsx` to conditionally display the task item based on user role and local storage setting. - Enhanced `use-sidebar-data.ts` to include task logs visibility for admin users only.
feat(web): show task logs only to administrators
WalkthroughThe change adds project design documentation and introduces administrator-controlled filtering of model test logs across backend queries, API contracts, usage-log UI state, navigation visibility, and localization. ChangesModel Test Log Filtering
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Admin as Administrator
participant UsageLogs as Usage-log UI
participant API as Log API
participant Model as Log model
Admin->>UsageLogs: Select include model test logs
UsageLogs->>API: Send include_model_test=true
API->>Model: Query logs and statistics
Model-->>API: Return matching results
API-->>UsageLogs: Render filtered logs and statistics
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/project/features.md`:
- Line 34: Update the “日志与统计” entry to specify that administrator log-list and
statistical queries exclude model-test logs by default, only administrators can
control their inclusion or exclusion, and personal-log queries retain their
existing behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 39207cc9-f3a6-493e-ad40-0dfd199b77a2
📒 Files selected for processing (27)
.codegraph/.gitignoreAGENTS.mdcontroller/channel-test.gocontroller/log.godocs/openapi/api.jsondocs/project/README.mddocs/project/architecture.mddocs/project/billing-and-data.mddocs/project/development-guide.mddocs/project/features.mddocs/project/frontend-design.mddocs/project/relay-pipeline.mdmodel/log.gomodel/log_filter_test.goweb/classic/src/components/layout/SiderBar.jsxweb/default/src/features/usage-logs/components/common-logs-filter-bar.tsxweb/default/src/features/usage-logs/lib/utils.tsweb/default/src/features/usage-logs/types.tsweb/default/src/hooks/use-sidebar-data.tsweb/default/src/i18n/locales/en.jsonweb/default/src/i18n/locales/fr.jsonweb/default/src/i18n/locales/ja.jsonweb/default/src/i18n/locales/ru.jsonweb/default/src/i18n/locales/vi.jsonweb/default/src/i18n/locales/zh-TW.jsonweb/default/src/i18n/locales/zh.jsonweb/default/src/routes/_authenticated/usage-logs/$section.tsx
| | 计费 | 模型倍率、固定价格、动态表达式计费、预扣、实际用量结算、失败退款和违规费用 | `relay/helper/price.go`、`service/billing_session.go`、`service/quota.go`、`pkg/billingexpr/` | 定价、钱包、日志和系统计费设置 | | ||
| | 钱包与充值 | 余额、兑换码、充值订单、邀请额度转移及多支付渠道 | `controller/topup*.go`、`controller/redemption.go`、`model/topup.go` | `features/wallet/`、`features/redemption-codes/` | | ||
| | 订阅 | 订阅计划、用户订阅、周期额度重置、余额/支付渠道购买及资金来源偏好 | `controller/subscription*.go`、`service/subscription_reset_task.go`、`model/subscription.go` | `features/subscriptions/`、`features/wallet/` | | ||
| | 日志与统计 | 请求日志、任务日志、用户/管理员统计、排行榜、渠道亲和统计和用量聚合;管理员通用日志默认排除渠道模型测试日志,可按需包含 | `controller/log.go`、`controller/usedata.go`、`controller/rankings.go`、`model/log.go` | `features/usage-logs/`、`features/dashboard/`、`features/rankings/` | |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Document the filter scope and permission boundary precisely.
This entry only says that administrator logs can optionally include model-test logs. State that administrator list and statistical queries exclude them by default, the include/exclude control is administrator-only, and personal-log queries retain their existing behavior.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/project/features.md` at line 34, Update the “日志与统计” entry to specify
that administrator log-list and statistical queries exclude model-test logs by
default, only administrators can control their inclusion or exclusion, and
personal-log queries retain their existing behavior.
Source: Coding guidelines
Important
📝 变更描述 / Description
管理员通用日志目前会混入渠道模型测试产生的消费日志,影响日常请求排查和统计阅读。本次改动使用模型测试日志已有的稳定标识,在管理员日志列表和统计查询中默认排除这类记录,并在筛选栏提供“排除/包含模型测试日志”切换。个人日志查询保持原有行为。
本次代码与 PR 描述由 Codex AI 辅助生成,提交者需人工复核后再合并。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。本 PR 不标记为 Bug fix。📸 运行证明 / Proof of Work
go test ./model -run TestAdminLogQueriesExcludeChannelTestsByDefault -count=1go test ./controller -run '^$' -count=1bun run typecheckoxlint通过;仓库现有usage-logs/api.ts↔lib/utils.ts循环依赖规则未纳入本次范围bun run i18n:syncbun run buildjq empty docs/openapi/api.jsonSummary by CodeRabbit
New Features
Bug Fixes
Documentation