fix(usage): make last-24-hours preset a true rolling window - #5698
Open
feitianbubu wants to merge 2 commits into
Open
fix(usage): make last-24-hours preset a true rolling window#5698feitianbubu wants to merge 2 commits into
feitianbubu wants to merge 2 commits into
Conversation
This was referenced Aug 16, 2026
|
LGTM 这个 PR 修复的是“近24小时”实际查询了两个自然日这一明显的功能 bug,整体改动方向正确,前后端时间格式和旧日期语义的兼容处理也没有发现实质性问题,建议合入 |
Contributor
Author
|
@Wei-Shaw 佬关注下 |
Owner
|
维护审计反馈:滚动 24 小时窗口修复了查询语义,但当前精确到秒的时间参数直接进入缓存 key,产生两个阻塞缺口:
另外,响应中的 date 仍用 endTime-24h 格式化成自然日,不能准确表达实际滚动窗口边界。 请为滚动窗口设计稳定的时间桶或显式有界缓存,并返回真实 start/end 时间元数据;补充连续请求缓存命中和淘汰测试。 |
feitianbubu
force-pushed
the
fix/rolling-24h-window-v2
branch
from
August 22, 2026 06:35
6a5f003 to
b8c7a36
Compare
…ho real boundaries
feitianbubu
force-pushed
the
fix/rolling-24h-window-v2
branch
from
August 22, 2026 06:56
b8c7a36 to
9821323
Compare
Contributor
Author
|
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.
Closes #5688
Closes #4703
问题
「近24小时」目前实际查的是「昨天+今天」两个自然日,最长能覆盖到约 48 小时的记录。接近 24 点时查看,数字比真实的 24 小时消费虚高近一倍;一过 0 点,昨天整天的数据瞬间掉出窗口,数字跳崖(#5688 与 #4703 报告的都是这个现象)。
影响面:用户使用记录页、管理端使用记录页、管理端仪表盘三个页面的默认值都是「近24小时」,打开页面看到的总消费/总请求/图表与显示语义不一致,容易误导用户。
原因是预设算完 now-24h 后把时间部分丢了,只传日期到后端,后端按整数天解析。
修改
YYYY-MM-DD整天语义完全不变的基础上,接受 RFC3339 标准时间;自选日期行为不变utils/dateRange.ts验证
go test -tags=unit ./...全部通过;pnpm typecheck通过DateRangePicker.spec.ts/DashboardView.spec.ts/UsageView.spec.ts共 15 个用例通过