fix: correct usage logs filtering - #4883
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThree log query functions and the usage logs table are refactored to unify filtering behavior. A new shared pattern builder implements contains-style partial matching with wildcard escaping, replacing prior conditional exact-match and full-name-only LIKE logic. The frontend table enables manual filtering mode. ChangesLog Search Filtering Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 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 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 |
Calcium-Ion
left a comment
There was a problem hiding this comment.
LGTM. 审了 diff:
后端 (model/log.go):
- 统一抽取了
logContainsPattern/applyLogContainsFilter函数,将所有 username/token_name/model_name 的过滤从精确匹配=/ 或不一致的 LIKE 改为统一的%escaped_input%模糊匹配。 - LIKE ESCAPE '!' 处理正确:先转义
!/%/_特殊字符,再两端加%。 LIKE ... ESCAPE '!'语法三库(SQLite/MySQL/PostgreSQL)都支持,无兼容问题。GetAllLogs、GetUserLogs、SumUsedQuota三个函数都统一了。
前端 (usage-logs-table.tsx):
- 加了
manualFiltering: true— 正确,因为过滤是服务端做的,不需要 react-table 的客户端过滤。
逻辑清晰,消除了重复代码。
This reverts commit 554defe.
This reverts commit 554defe.
This reverts commit fb672e9.
This reverts commit 554defe.
This reverts commit 554defe.
Important
📝 变更描述 / Description
(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)
完善使用日志查询。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
(请在此粘贴截图、关键日志或测试报告,以证明变更生效)

Summary by CodeRabbit
Release Notes