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

未關閉
#438 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@fx-kurumi 已經在處理了。

開始於 2026年11月13日。

  • #439 來自 @fx-kurumi —— 未關閉

評估

難度
3/5
預估耗時
半天
新手友好度
25/100
Issue 類型
重構
描述清晰度
描述清楚
活躍度
停滯
技術堆疊
go
領域
backend

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

现状问题

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 的既有失败除外)。
主要語言
Go
星號
141
分支
28
平均合併
1 天 15 小時
30 天內合併 PR
113

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

Tencent/LoopForge 的其他 Issue

查看 Tencent/LoopForge 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。