Repository navigation
fix(dataStats): 趋势图缺日按前一日补齐,避免未采集被画成归零 - #69
Merged
PersonalCao merged 3 commits intoNov 6, 2026
Merged
Conversation
added 3 commits
November 7, 2026 01:50
- statsUtils: 新增 isCollected 判据(plays/likes/comments 任一 >0 才算真正采集过), 只有 fans 的残缺日(fans 历史回填产物)同样按未采集处理 - statsUtils: pickDaily 改为按自然日铺满 count 天,未采集日继承前一已采集日数值并打 __filled;窗口起点前无任何采集数据时仍留 __missing(不给值、不画 0) - StatsOverview: chartDatasets 标记补值点;卡片「较昨日」只与最近一个真实采集日比较, 避免 delta 被缺日放大成一整天的增长 - StatsLineChart: 补值点画空心圆、tooltip 数值前缀 ≈ 以示估算;__missing 保持断点 - 新增 scripts/test-stats-trend.js(yarn test:stats-trend) 背景:2026-11-06 采集任务因网络中断整轮未执行,daily.json 缺当日键;原实现按日期键 并集渲染,11-06 被画成 0(11-05 总播 3695 → 0 → 11-07 3803),观感为断崖,卡片 delta 同时显示成 +3803。补值只存在于视图层,daily.json 不写入任何补估值。
- pickWeekly/pickMonthly:同周(月)里优先取真实采集行;只在整周都没有采集时 才退回残缺行兜底,避免 fans-only 的补采行把整周播放数拉低成 0 - test:stats-trend 补周/月两条断言(含整周无采集的兜底分支)
Collaborator
Author
|
请 review。 范围:只改数据统计页趋势图(renderer 纯函数 + 两个展示组件),不动采集层、不动 建议重点看三处:
验证: 已知取舍:日视图固定 30 个自然日,新账号左侧会出现空格(表示"没数据"而非"归零")。如果更希望保留"有多少天画多少天",我可以改成只在「中间缺日」时补、首尾不补——请指示。 |
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.
问题
数据统计页的趋势图只按
daily.json里实际存在的日期键渲染。某一日没采集成功时,这一天要么整行缺失(dy/ks),要么只有 fans 历史回填来的一个残缺行(sph),主进程readOverview又把缺的指标补 0,于是:实证:2026-11-06 21:30 的采集任务因网络中断(模型接口不可达,重试到 21:39 放弃)整轮未执行,三平台当日
daily.json无键;用户看到的就是这条断崖。数据本身没有归零——11-05→11-07 实际是 +108 播。方案
补值只发生在视图层,
daily.json与采集逻辑一行不改:statsUtils.isCollected(row):plays>0 || likes>0 || comments>0才算真正采集过。只有 fans 的残缺日(fans 历史回填产物)同样按未采集处理——这是最容易误判的一类。statsUtils.pickDaily:以最后一条数据为终点,按自然日铺满count天。未采集日继承前一已采集日的全部指标并打__filled;窗口起点之前没有任何采集数据时仍留__missing(不给值,不画 0)。StatsOverview.chartDatasets:补值点标记为filled;cards只跟最近一个真实采集日比较,避免 delta 被缺日放大。StatsLineChart:补值点画空心圆(fill=none+ 同色描边)、tooltip 数值前缀≈,让估算点可辨;__missing仍然断开折线。验证
scripts/test-stats-trend.js(yarn test:stats-trend):dailyToRows 升序、isCollected 判据、缺日继承前值、残缺日按缺日处理、连续两日缺失都继承同一真实值、起点前__missing、空输入。全部通过。yarn test:data-stats通过(未改动采集层,回归确认)。yarn build:dir通过。filled=true,SVG 该点fill="none";卡片 delta 回到 +1(粉丝)/ +3(评论),不再是 +3803。影响面与风险
daily.json,也不会进入平台数据台账与日报。