Skip to content

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

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

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

Conversation

@kilisamemarisaaa

Copy link
Copy Markdown

关联信息

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

变更内容

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

变更原因

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

验证

  • go test ./...
  • go vet ./...
  • go build ./...
  • go test internal/apps/project/item_filter.go internal/apps/project/item_filter_test.go
  • git diff --check

例行检查

  • 我已阅读并理解贡献者公约
  • 我已阅读并同意贡献者许可协议 (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

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 里

@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
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.

2 participants