fix(health): use effective list filters #120

Merged
wbtiger merged 1 commits from wangyue111/gitlink-cli:fix/health-list-filters into master 2026-06-08 02:24:55 +08:00
Contributor

背景
检查近期合入的 gitlink-health 后,发现 health +fetch 仍然使用旧的列表筛选方式:

  • PR 列表调用 /api/{owner}/{repo}/pulls.json 并传 state=open/closed/merged
  • Issue 列表调用 /api/v1/{owner}/{repo}/issues.json 但传 state=open/closed

线上验证发现这些参数会被服务端忽略或不能正确筛选:

  • /api/Gitlink/gitlink-cli/pulls.json?state=merged 仍返回 open PR
  • /api/Gitlink/gitlink-cli/pulls.json?status=1 仍返回 open PR
  • /api/v1/Gitlink/gitlink-cli/issues.json?state=open 和 state=closed 返回混合结果
  • 正确接口是 PR v1 的 status=0/1/2,以及 Issue v1 的 category=opened/closed

这会导致 health +fetch 写入 SQLite 的 PR/Issue 状态混乱,影响后续健康度统计。

修复内容

  1. PR 列表改用有效的 v1 接口和状态参数:

    • GET /api/v1/{owner}/{repo}/pulls.json?status=0 open
    • GET /api/v1/{owner}/{repo}/pulls.json?status=1 merged
    • GET /api/v1/{owner}/{repo}/pulls.json?status=2 closed
  2. Issue 列表改用有效的 category 参数:

    • GET /api/v1/{owner}/{repo}/issues.json?category=opened
    • GET /api/v1/{owner}/{repo}/issues.json?category=closed
  3. savePull 兼容 v1 PR list 返回结构:

    • PR number 支持 index
    • 状态支持 status=open/merged/closed
    • author 支持 issue.author.login
    • tag 支持 issue.issue_tags

测试

新增 health 单元测试覆盖:

  • PR 列表必须请求 /v1/{owner}/{repo}/pulls 并发送 status,不再发送 state
  • Issue 列表必须发送 category,不再发送 state
  • savePull 能正确保存 v1 list 返回的 PR number/status/author/tag/merged_at

已验证:

说明

这是一个功能正确性修复,不改变 health +fetch 的 CLI 参数,只修正底层调用的 OpenAPI 路径和参数映射。

背景 检查近期合入的 gitlink-health 后,发现 health +fetch 仍然使用旧的列表筛选方式: - PR 列表调用 /api/{owner}/{repo}/pulls.json 并传 state=open/closed/merged - Issue 列表调用 /api/v1/{owner}/{repo}/issues.json 但传 state=open/closed 线上验证发现这些参数会被服务端忽略或不能正确筛选: - /api/Gitlink/gitlink-cli/pulls.json?state=merged 仍返回 open PR - /api/Gitlink/gitlink-cli/pulls.json?status=1 仍返回 open PR - /api/v1/Gitlink/gitlink-cli/issues.json?state=open 和 state=closed 返回混合结果 - 正确接口是 PR v1 的 status=0/1/2,以及 Issue v1 的 category=opened/closed 这会导致 health +fetch 写入 SQLite 的 PR/Issue 状态混乱,影响后续健康度统计。 修复内容 1. PR 列表改用有效的 v1 接口和状态参数: - GET /api/v1/{owner}/{repo}/pulls.json?status=0 open - GET /api/v1/{owner}/{repo}/pulls.json?status=1 merged - GET /api/v1/{owner}/{repo}/pulls.json?status=2 closed 2. Issue 列表改用有效的 category 参数: - GET /api/v1/{owner}/{repo}/issues.json?category=opened - GET /api/v1/{owner}/{repo}/issues.json?category=closed 3. savePull 兼容 v1 PR list 返回结构: - PR number 支持 index - 状态支持 status=open/merged/closed - author 支持 issue.author.login - tag 支持 issue.issue_tags 测试 新增 health 单元测试覆盖: - PR 列表必须请求 /v1/{owner}/{repo}/pulls 并发送 status,不再发送 state - Issue 列表必须发送 category,不再发送 state - savePull 能正确保存 v1 list 返回的 PR number/status/author/tag/merged_at 已验证: - git diff --check - GOPROXY=https://goproxy.cn,direct go test ./shortcuts/health ./... - go vet ./... 说明 这是一个功能正确性修复,不改变 health +fetch 的 CLI 参数,只修正底层调用的 OpenAPI 路径和参数映射。
wangyue111 added 1 commit 2026-06-05 14:56:09 +08:00
wbtiger merged commit 55805aa13d into master 2026-06-08 02:24:55 +08:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Gitlink/gitlink-cli#120
No description provided.