【架构优化】从 httpapi.filterIssues 中拆出负责人与关键词匹配谓词

Đang mở
#438 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@fx-kurumi đang làm issue này rồi.

Từ ngày 13/11/2026.

  • #439 của @fx-kurumi — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
25/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
go
Lĩnh vực
backend

Hướng nghiên cứu

Start in internal/httpapi/issues.go and read filterIssues, paying attention to the assignee and keyword branches inside its loop. The issue asks for two private predicates, issueMatchesAssignee and issueMatchesQuery, with the original matching behaviour kept intact. Run go test ./internal/httpapi/ to confirm the existing filter behaviour before changing anything. Note that pull request #439 is already open against this issue, so check that work before starting.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

现状问题

internal/httpapi/issues.go 的 filterIssues 在一个循环里同时处理项目、状态、来源、负责人、关键词五类过滤条件,其中:

  • 负责人过滤用了 unassigned 分支 + matched 临时变量的两层嵌套 if/else;
  • 关键词过滤内联拼接检索文本(标题/ID/编号/TAPD ID/外部 ID),并在每条记录上重复计算 needle。

循环体被这两段嵌套逻辑撑长,难以单独阅读和测试。

重构方案

  • 拆出 issueMatchesAssignee(item, assignee) bool:保持 unassigned(大小写不敏感)、按用户 ID 数字匹配、按 AssigneeID 大小写不敏感匹配的原语义;
  • 拆出 issueMatchesQuery(item, needle) bool:保持原检索文本拼接与 fuzzyIssueTitleMatch 回退;
  • filterIssues 循环体改为调用上述两个谓词,needle 在循环外计算一次;排序逻辑不动。

影响范围

仅 internal/httpapi/issues.go 中 filterIssues 及新增两个包内私有函数;对外接口、查询参数语义、排序规则均不变。

验证方式

  • 新增 issue_filter_predicates_test.go 覆盖负责人(空、unassigned、用户 ID、AssigneeID 大小写)、关键词(标题、编号、外部 ID、模糊匹配、不匹配)以及 filterIssues 组合过滤结果;
  • gofmt、go vet ./internal/httpapi/、go test ./internal/httpapi/ 通过(本机缺 Chromium 的既有失败除外)。
Ngôn ngữ chính
Go
Star
141
Fork
28
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
113

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Tencent/LoopForge

Tất cả issue của Tencent/LoopForge

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.