Skip to content

fix(project): filter duplicate items in update batches - #197

Open
kilisamemarisaaa wants to merge 2 commits into
linux-do:masterfrom
kilisamemarisaaa:fix/project-filter-batch-duplicates
Open

kilisamemarisaaa wants to merge 2 commits into
linux-do:masterfrom
kilisamemarisaaa:fix/project-filter-batch-duplicates

Conversation

@kilisamemarisaaa

@kilisamemarisaaa kilisamemarisaaa commented Aug 31, 2026 •

Copy link
Copy Markdown

关联信息

本 PR 修复项目更新时启用重复过滤仍会写入同一请求内重复内容的问题。

变更内容

  • 提取 filterNewItems,同时过滤数据库已有内容和当前请求内的重复内容。
  • 让 CreateItemsWithFilter 与 GetFilteredItemsCount 复用同一逻辑,确保写入数量和 TotalItems 保持一致。
  • 添加覆盖已存在项、批次内重复项、顺序保持和空输入的单元测试。

变更原因

更新接口的 enable_filter 选项原先只检查数据库中的内容。比如项目已有 a,一次提交 [a, b, b] 时会写入两个 b,但项目数量只按“非已有项”估算,导致重复库存和数量统计不一致。服务端应在客户端过滤之外保证该约束。

验证

  • go vet ./...:通过。

  • go build ./...:通过。

  • 移动前后 filterNewItems 的函数文本一致;从 utils.go 原样提取 helper 后,与原有 item_filter_test.go 执行隔离 named-file 测试,三个子用例通过(已存在项与批次去重、顺序、空输入)。该检查不是全项目测试。

  • git diff --check:通过。

  • 全项目 go test ./...:本地未通过。默认缺少 config.yaml;设置 CONFIG_PATH 指向仓库 config.example.yaml 后,包初始化因本地 127.0.0.1:3306 没有 MySQL 服务而失败。尚未完成数据库集成验证。
    例行检查

  • 我已阅读并理解贡献者公约

  • 我已阅读并同意贡献者许可协议 (CLA)

  • 我知晓本 PR 做出的是实质性功能修复

@kilisamemarisaaa

Copy link
Copy Markdown
Author

感谢维护者审阅。这个改动只影响 enable_filter=true 的项目追加内容路径:会同时过滤数据库已有项和同一请求内的重复项,保持首次出现顺序;go test ./...、go vet ./...、go build ./... 和 license 检查均已通过。

@kilisamemarisaaa

Copy link
Copy Markdown
Author

@chenyme 如方便,烦请帮忙审核一下。该 PR 修复 enable_filter=true 时同一批追加内容内重复项未被过滤的问题,并让数量统计与实际写入保持一致;改动限定在项目追加内容路径,测试与构建均已通过。

@github-actions

Copy link
Copy Markdown

此 PR 长期无活动,将在 14 天后自动关闭。如需继续讨论请回复

@github-actions github-actions Bot added the Stale label Sep 15, 2026
Comment thread internal/apps/project/item_filter.go Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

放 utils.go 里

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已在 42e3bbd 将 helper 原样移到 utils.go,删除独立的 item_filter.go。已核对移动前后函数文本一致;现有三个表驱动用例在隔离 helper 测试中通过,go vet ./... 和 go build ./... 通过。全项目 go test ./... 仍受本地 MySQL 未运行影响,已在 PR 验证部分明确说明。

@github-actions github-actions Bot removed the Stale label Sep 19, 2026
Co-Authored-By: EvoX <evox@evomap.ai>
@kilisamemarisaaa
kilisamemarisaaa force-pushed the fix/project-filter-batch-duplicates branch from 37ee8e7 to 5fcb248 Compare October 2, 2026 03:22
@github-actions

Copy link
Copy Markdown

此 PR 长期无活动,将在 14 天后自动关闭。如需继续讨论请回复

@github-actions github-actions Bot added the Stale label Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants