Repository navigation
fix(dashboards): remove fabricated trend deltas from CRM/Sales/Service tiles - #608
Merged
Merged
Conversation
…e tiles
Twelve KPI tiles across the CRM, Sales and Service dashboards carried a
hardcoded period-over-period delta (`trend: { value: 12.5, direction: 'up',
label: 'vs last month' }` and eleven siblings). No query produced those
numbers and nothing recomputed them: every tenant, every dataset and an
empty database all rendered the same "+12.5% vs last month".
A period-over-period delta is a measurement — it can only come from
comparing this period's result against the previous period's. Until the
console can run that comparison for dataset metrics (widget `compareTo`),
a tile shows the number it actually measured and nothing else. The
executive dashboard already dropped its own on this reasoning (#500);
this makes the other three consistent with it.
Also drops the now-empty `avgDealSizeMetricWidget` override on the CRM
dashboard — with the trend gone it only re-passed the factory's own
`options: { icon: 'bar-chart' }`.
Guarded by a new assertion in `test/analytics-integrity.test.ts`, which
walks every dashboard widget and fails on a `trend` carrying a literal
number at any nesting depth, so hand-typed deltas cannot creep back into
metadata.
Fixes #587
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019SS7C5SXpniKeCApxgARyf
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
os-zhuang
marked this pull request as ready for review
August 2, 2026 11:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #587
Description
CRM、Sales、Service 三个看板的 12 个 KPI 卡片各自携带一个写死的环比涨跌幅,例如
trend: { value: 12.5, direction: 'up', label: 'vs last month' }。这些数字不是任何查询算出来的,也没有任何东西会重算它们:无论哪个租户、哪份数据集,哪怕是一个刚初始化、一条记录都没有的数据库,
卡片都照样宣称 “+12.5% vs last month”,方向朝上还是朝下也纯属手写时的选择。
环比涨跌幅本质上是一次测量——它只能来自“本期结果对比上期结果”的真实比较查询。在控制台能为
dataset metric 跑这个比较(widget
compareTo)之前,卡片只展示它真正测到的那个数字,不多展示任何东西。Executive 看板在 #500 已经按同样的理由删掉了自己那批伪造百分比,本 PR 让其余三个看板与它保持一致,
不再是“一个诚实、三个编造”的半吊子修复。
顺带删掉了 CRM 看板上
avgDealSizeMetricWidget已经空掉的 override:trend 去掉之后,它只是把工厂自己声明的
options: { icon: 'bar-chart' }原样再传一遍,什么也没说。三个看板的文件头注释各补了一段说明,写清楚“为什么这里没有 trend”以及未来重新引入时的正确来源,
避免下一个作者(或下一个 AI)把它当成遗漏再补回来。
Type of Change
Related Issues
Fixes #587
Related to #500
Changes Made
src/dashboards/crm.dashboard.ts:删除 4 处写死的trend;avgDealSizeMetricWidget的空 override 一并删除;文件头注释更新。src/dashboards/sales.dashboard.ts:删除 4 处写死的trend;文件头注释补充理由。src/dashboards/service.dashboard.ts:删除 4 处写死的trend;文件头注释补充理由。test/analytics-integrity.test.ts:新增 pin test —— 遍历每个看板 widget,任意嵌套层级下只要出现携带字面数字的trend(trend: 12.5或trend: { value: 12.5, … })即失败。先在修复前跑过,确认它准确抓出全部 12 处;修复后转绿。.changeset/no-fabricated-dashboard-trends.md:patch 版本变更说明。验收条件已满足:
grep -rn "trend:" src/dashboards/现在零命中。Testing
npm test)npm run lint)npm run build)pin test 在修复之前的输出(证明它确实咬得住,而不是空转):
Screenshots
无 UI 截图:本 PR 只做删除。受影响的卡片仍然渲染同一个实测数值,只是下方那行伪造的涨跌幅消失了。
Checklist
pnpm changeset) — required on every PR, or theskip-changesetlabel is appliedAdditional Notes
为什么 guard 放在元数据层而不是源码 grep。 验收里写的是
grep -rn "trend:" src/dashboards/,但 pin test 遍历的是
objectstack.config.ts注册后的看板对象树。这样更严格:它不关心写法(对象字面量、工厂函数、spread、helper 拼装都一样抓),只关心最终发布出去的元数据里有没有这个字面数字——
“声明即生效”的那一面。同时它对嵌套深度不敏感,因为控制台把
options当自由字段包读,手写的 trend 可以从任意深度冒出来。
文档漂移(不在本 PR 范围)。
content/docs/analytics/dashboards.mdx描述的看板卡片与实际元数据大面积对不上,已按 Prime Directive #10 另开 issue #610 记录,未在本 PR 内顺手改。
🤖 Generated with Claude Code
https://claude.ai/code/session_019SS7C5SXpniKeCApxgARyf