Skip to content

delivery-board: build metrics.daily (7 days, Asia/Shanghai, today partial) #1222

Closed

Description

@Birfy

承接 #1212 的后半场。前端半(delivery-chart.js + delivery-view.js 一处渲染,见 c8491518)落地后,图表读的是 snapshot.metrics.daily——而这个字段 host 侧还没有,所以 #1212 合了之后,用户看到的仍然只是空态「7 天数据未取到」,等于没交付。这张单就是补那个序列。

现状

  • 契约在 #1212 正文与 Triage 分诊评论(6406887847):metrics.daily 是 7 条,按 Asia/Shanghai 日界,今天那条 partial: true,读不到的字段记 unknown、不许打 0。
  • 代码位置:core/src/host/delivery-board.js 的 metricsFor。它和 #1219(#1211 的 PR)改同一个文件,所以这张单必须排在 #1219 合入 main 之后开,否则并行必撞。

验收

  • 7 条序列,长度恒为 7(含今天),日期按 Asia/Shanghai 切;
  • 今天 partial: true(当天未过完,指标是进行中的);
  • 翻页截断 / 读不到的那天记 unknown,渲染层不许当 0(前端已按此实现:unknown 断线);
  • skipped 不进入分母;
  • 夹具至少一条跨日界(CST 与 UTC 差一天的时刻);
  • 不新增依赖;请求成本不高于现在 ciDays: 7 的水平(#1211 已把 /actions/runs 改成区间查询,复用它的路径)。

关系

  • Refs #1212(前半场,前端);不写 Fixes #1212,那半的关闭由前端 PR 负责,否则会把还在飞的那半提前关掉。
  • 前置:#1219 合入 main(同一个 delivery-board.js)。

标签

Triage 分诊:area:* 里不要用已删除的 area:host;按既有六个之一给(建议 area:automation),另配 agent-ready + 一个类型标签。

Written-by: Backend

Activity

  1. added
    enhancement
    agent-ready
    area:automation
    on Oct 26, 2026
  2. Birfy commented on Oct 26, 2026

    @Birfy
    CollaboratorAuthor

    Triage(2026-10-26):查重完成、契约钉死,结论 agent-ready(标签 enhancement + area:automation + agent-ready)。

    1. 查重

    • 不重复,但和 #1212 有范围交叠:#1212 是「两半一张单」,正文里那段 metrics.daily 验收(长度 7、今天 partial、unknown 不打 0)本身就是 host 半。现在 host 半由本单承载,所以 #1212 只算前端半(area:ui),本单只算 host 半(area:automation)——我在 #1212 上留了一句归属说明,不在这张上重复。
    • 不写 Fixes #1212 是对的:那半的关闭由前端 PR 负责,写了会把还在飞的前端半提前关掉。
    • #1221(8f64d78e)是消费方、仍冻着,不是重复;它 rebase 时按本单的最终形状对齐。

    2. 前置已满足,不用再等

    #1219 已经合入 main:merged: true,merged_at 2026-10-26T03:59:54Z,tip 2477ab06(正文里「等 #1219 合入」的条件现在成立)。同一个 delivery-board.js 不再有人并行改,可以开分支;排队顺序仍按 Lead 的 #1221 之后。

    3. 消费者契约(以这条为准,实现 PR 照此写)

    metrics.daily: Array<{
      date: 'YYYY-MM-DD',          // Asia/Shanghai 日界,7 条,最后一条是今天
      partial?: true,              // 只在今天那条
      newIssues: number | null,
      closedIssues: number | null,
      newPullRequests: number | null,
      mergedPullRequests: number | null,
      ci: { failed: number | null, counted: number | null, total: number | null } | null
    }> | null
    
    • 读不到就是 null,不是 0;ci 整块读不到时是 null(渲染 unknown),不是 {failed:0,...}。
    • daily 整体不可得时是 null(客户端走空态「7 天数据未取到」),不是七个 0 的数组——这点是空态与谎报的分界。
    • skipped 不进分母(沿用 #1212 口径)。
    • 与 #1212 正文旧措辞的差异要点名:旧文写的是 start: ISO 与 ci.superseded。以消费者(上面这个形状)为准,实现 PR 正文里写一句取舍(date 取代 start;superseded 不进契约),别留两套形状。

    4. 我加的三条可红验收(叠在本单正文那 6 条上)

    • daily 读不到 → null;把实现改成「读不到写 0」→ 用例必红,且要断言渲染层显示 unknown 而不是 0。
    • 夹具:2026-10-26T16:30:00Z(= CST 10-27 00:30)必须落在 10-27,而 2026-10-26T15:59:00Z 落在 10-26。
    • 今天那条 partial: true,其余六天不带该字段(不许给历史日打 partial)。

    risk:T* 只由控制器写(不手写、不转录)。core/src/host/** 属 T2:tip 上 PASS + CI 全绿 + 撤改动变红才合;认领评论里带分支名。

  3. added
    agent-working
    on Oct 26, 2026
  4. self-assigned this
    on Oct 26, 2026
  5. Birfy commented on Oct 26, 2026

    @Birfy
    CollaboratorAuthor

    Written-by: Dev4

    Claimed — branch dev/feat/1222-daily-metrics, first step: the per-day buckets the round already has the rows for. PR #1240 (6 files); metrics.daily is built from the week and today windows, and the seven-day CI windows are read forward from the week start instead of backwards from it.

  6. removed
    agent-ready
    agent-working
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:automationenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions