Skip to content

fix some bugs#2

Merged
CSCITech merged 1 commit into
mainfrom
cscitech
Jun 28, 2026
Merged

fix some bugs#2
CSCITech merged 1 commit into
mainfrom
cscitech

Conversation

@CSCITech

Copy link
Copy Markdown
Contributor

⚠️ 提交说明 / PR Notice

Important

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

📝 变更描述 / Description

补强使用日志 retry 筛选的回归测试覆盖。

本次在 retry 筛选测试数据中新增了一条属于其他用户的 retry_log 日志,并更新 GetUserLogs 断言,确保用户日志查询在应用 retry 条件时仍然保留 user_id 作用域,不会把其他用户的重试日志返回给当前用户。同时同步调整全局日志查询与统计查询的预期值,使测试数据覆盖全局 retry 筛选和用户级 retry 筛选两种路径。

🚀 变更类型 / Type of change

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

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

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

📸 运行证明 / Proof of Work

go test ./model -run "Test(GetAllLogsRetryFilter|GetUserLogsRetryFilter|SumUsedQuotaRetryFilter)$"
ok  	github.com/MAX-API-Next/MAX-API/model	12.220s

bun test src/features/usage-logs/lib/utils.test.ts
6 pass
0 fail

git diff --check
# no output

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9e9d9882-49cc-4ff2-91fd-1db47eddb3c5

📥 Commits

Reviewing files that changed from the base of the PR and between 7da36ae and 29c3310.

📒 Files selected for processing (1)
  • model/log_test.go
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.go: All JSON marshal/unmarshal operations in Go business code must use the wrapper functions in common/json.go (common.Marshal, common.Unmarshal, common.UnmarshalJsonStr, common.DecodeJson, common.GetJsonType); do not directly import or call encoding/json for marshal/unmarshal logic.
All database code must remain compatible with SQLite, MySQL 5.7.8+, and PostgreSQL 9.6+; prefer GORM abstractions, avoid raw SQL unless it has cross-database fallbacks, use shared helpers for reserved columns and boolean literals, and ensure migrations work on all three databases.

**/*.go: All JSON marshal/unmarshal operations in business Go code must use the wrapper functions in common/json.go (common.Marshal, common.Unmarshal, common.UnmarshalJsonStr, common.DecodeJson, common.GetJsonType); do not directly call encoding/json for marshal/unmarshal logic.
Database code must remain compatible with SQLite, MySQL 5.7.8+, and PostgreSQL 9.6+ by using GORM abstractions where possible, avoiding database-specific features without fallback, using the shared DB-specific column/value helpers (commonGroupCol, commonKeyCol, commonTrueVal, commonFalseVal), and ensuring migrations work on all three databases.
For request structs parsed from client JSON and later re-marshaled to upstream providers, especially in relay/convert paths, optional scalar fields must use pointer types with omitempty so explicit zero/false values are preserved and omitted fields remain nil.

Files:

  • model/log_test.go
🔇 Additional comments (1)
model/log_test.go (1)

33-35: LGTM!

Also applies to: 51-53, 66-68, 130-143


📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Expanded log-related test coverage to include an additional matching record.
    • Tightened user-log checks to ensure returned entries belong to the expected user.
    • Updated aggregate usage expectations to match the broader test dataset.

Walkthrough

In model/log_test.go, a new UserId==2 log entry is added to createRetryFilterLogs. The three retry-filter tests are updated: expected log count rises to 3, a UserId==1 assertion is added per returned log, and quota aggregate expectations are revised.

Retry Filter Test Updates

Layer / File(s) Summary
Fixture addition and updated test assertions
model/log_test.go
createRetryFilterLogs adds a new UserId==2 log record; TestGetAllLogsRetryFilter expects 3 logs, TestGetUserLogsRetryFilter asserts UserId==1 on each result, and TestSumUsedQuotaRetryFilter uses new aggregate values.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A bunny hops in with one more log,
UserId two joins the catalog.
Quotas revised, the counts now three,
Assertions updated, tests run free.
🐇 All filters pass — hop hop hooray!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and generic, so it does not clearly describe the retry-filter test updates. Rename it to something specific like "Expand retry-filter regression tests for usage logs".
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly matches the changeset and explains the retry-filter test coverage updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • ✅ Committed to branch successfully - (🔄 Check to regenerate)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cscitech

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

@MAX-API-Next MAX-API-Next deleted a comment from coderabbitai Bot Jun 27, 2026
@CSCITech
CSCITech merged commit ecb2dd4 into main Jun 28, 2026
4 checks passed
This was referenced Jun 30, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jul 8, 2026
11 tasks
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