【架构优化】从 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 摘要。