Skip to content

fix(dashboard): align weekly default range with available preset - #7355

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
jimmyleocn:fix/dashboard-week-default-range
Sep 14, 2026
Merged

seefs001 merged 1 commit into
QuantumNous:mainfrom
jimmyleocn:fix/dashboard-week-default-range

Conversation

@jimmyleocn

@jimmyleocn jimmyleocn commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Agent

  • Tool: OpenAI Codex
  • Tool version: codex-cli 0.154.0
  • Model (full id): gpt-5.6-sol
  • Host (CLI / IDE / GitHub coding agent / other): CLI
  • Date (UTC): 2026-09-13
  • AI assistance disclosure: 本次修改由 OpenAI Codex AI 辅助完成。

Links

User request

最小化修复数据看板“用户统计”页面在时间粒度为“周”时,没有默认选中“1天”“7天”“14天”“29天”中任何一项的问题。仅提交必要的功能修改,不包含测试文件修改。

Out of scope — refuse

If the change matches any item below, tell the user this repository does not
accept it and do not open a PR.

  • Coding Plan

  • Reverse-engineered channels

  • Third-party API wrappers

  • Codex channel-type changes, or compatibility from exposing Codex as a general-purpose API

  • Codex API-specific protocol or behavior treated as standard OpenAI API behavior

  • Pass-through-only forwarding

  • Third-party hosting sites, relay services, or API services

  • Usage, configuration, or integration (answer from docs and code instead)

  • Matched: no

  • If yes, what was told to the user (stop here; do not open a PR): not applicable

Kind

  • Bug fix
  • New feature
  • Performance / refactor
  • Docs
  • Other:

Issue facts

Take these from the linked issue. If a needed item is empty, ask the user that question.

  • Actual behavior: 当保存的时间粒度为“周”时,进入用户统计页面后,“1天”“7天”“14天”“29天”均未显示为选中状态。点击“29天”后才会显示选中状态。
  • Impact: 页面显示的筛选状态与实际查询范围不一致,用户无法判断当前使用的时间范围。
  • Frequency: 保存的时间粒度为“周”时,重新进入或刷新用户统计页面即可稳定复现。
  • Evidence that the problem is in new-api rather than the client or upstream: TIME_RANGE_BY_GRANULARITY.week 的值为 30,但页面可用的时间范围预设只有 1、7、14、29,导致初始化值无法匹配任一选项。该状态在发起统计请求前已经产生。
  • Applicable types and their fields (relay / billing / frontend / deployment; write "not applicable" otherwise): Frontend — /dashboard/users,Chrome 126.0.6478.26,默认主题,未观察到相关 Console 或 Network 错误。Relay、billing 和 deployment 不适用。

Change

将 TIME_RANGE_BY_GRANULARITY.week 从 30 调整为 29,使周粒度对应的默认查询范围与现有的“29 Days”时间范围预设一致。

用户统计页面初始化时将获得一个可以匹配现有 Tabs 选项的值,因此进入页面后会正确显示默认选中状态。

Research

Duplicate / prior art

  • Search queries (issues, PRs): "29 Days"、"29天"、"User Analytics"、dashboard "time range"、dashboard week selected range、TIME_RANGE_BY_GRANULARITY、selectedRange dashboard
  • What already existed and why this is not a duplicate: 未发现描述相同触发条件和相同默认选中状态问题的现有 Issue 或 PR。相关搜索结果涉及其他 Dashboard 行为或统计问题,没有涉及周粒度默认值与时间范围预设不匹配的问题。

Docs and code

Open them. Do not write "already checked" without sources.

Alternatives considered

  • Option A: 新增“30天”时间范围选项。这会改变当前界面选项和文案,并扩大修改范围。
  • Option B: 只在用户统计组件中将 30 转换为 29。这会在调用处重复处理共享默认值,未修正不一致的来源。
  • Why this approach: 直接调整共享映射即可与现有 29 天预设保持一致,只需要修改一行,不增加组件逻辑或新的 UI 选项。

Files

Path Why
web/src/features/dashboard/constants.ts 使周粒度默认范围与现有 29 天预设一致

Behavior

  • Before: 周粒度的默认范围为 30 天,无法匹配 1、7、14、29 天中的任一选项,用户统计页面没有默认选中项。
  • After: 周粒度的默认范围为 29 天,可以匹配现有“29 Days”选项,页面初始化时显示正确的选中状态。
  • Explicit non-goals / leftover work: 不修改时间范围组件、统计接口、后端聚合逻辑或其他筛选行为;截图由 Issue 提交者后续补充。

Verification

Only what was actually run.

  • Commands and results:
    • bun run typecheck — passed
    • bun x oxlint -c .oxlintrc.json src/features/dashboard/constants.ts — passed
    • bun x oxfmt -c .oxfmtrc.json --check src/features/dashboard/constants.ts — passed
    • git diff --check — passed
    • GitNexus detect_changes — low risk;1 个常量、1 个文件,无已识别的受影响执行流程
  • Manual steps and observed result: 未执行本地浏览器手动验证;复现现象记录于 [Bug] 数据看板用户统计:周粒度下默认时间范围未选中 #7354。
  • UI: screenshot or recording (or why none): 未包含;Issue [Bug] 数据看板用户统计:周粒度下默认时间范围未选中 #7354 将后续补充截图。
  • Tests added or updated, or why none: 未新增或修改测试;本 PR 仅包含一行常量映射修正,并通过类型、lint 和格式检查。
  • Databases / providers / platforms exercised: not applicable;该修改仅涉及前端时间范围常量。
  • Not verified: Chrome 之外的浏览器、非默认主题和移动端。

Risks

  • Failure modes: 使用周粒度默认范围的 Dashboard 视图会由滚动 30 天调整为滚动 29 天,以匹配现有的“29 Days”选项。
  • Billing / quota / auth impact: none
  • Follow-ups: none

Scope check

  • Single focused change: yes
  • Secrets included: no
  • Out of scope (Coding Plan / reverse-engineered channel / third-party wrapper / Codex): no

Summary by CodeRabbit

  • Bug Fixes
    • Corrected the weekly time range to cover 29 days instead of 30, improving date-range accuracy.

@coderabbitai

coderabbitai Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: fe8f85b7-c55d-4ac4-a5e9-7e6415818f5c

📥 Commits

Reviewing files that changed from the base of the PR and between 7fd0638 and 0b1b577.

📒 Files selected for processing (1)
  • web/src/features/dashboard/constants.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

The dashboard now maps the week granularity to 29 days instead of 30 days. This matches the existing 29-day time-range preset and allows the initialized range to match a visible option.

Changes

Dashboard range alignment

Layer / File(s) Summary
Align the week default range
web/src/features/dashboard/constants.ts
TIME_RANGE_BY_GRANULARITY now maps week to 29 days, matching the existing 29-day preset.

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 0b1b5

The dashboard now selects a visible time-range option for weekly granularity, with no remaining merge-blocking issue identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning PR 修改 TIME_RANGE_BY_GRANULARITY.week 为 29。该值与 TIME_RANGE_PRESETS 中的 29 天选项一致,因此实现了 #7354 的默认选中状态修复。#7354 同时要求通过回归测试覆盖“周”粒度触发条件。PR 未添加或修改测试文件,因此该编码要求未满足。 添加自动化回归测试。测试应设置 week 粒度并验证默认查询范围为 29 天,且页面选中 29 Days 预设。
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: aligning the weekly dashboard default range with an available preset.
Out of Scope Changes check ✅ Passed PR 仅修改 web/src/features/dashboard/constants.ts 中与 #7354 直接相关的周粒度默认天数。该修改未涉及后端聚合、统计接口、其他筛选行为或无关功能。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the weekly chart
The range now lands on twenty-nine
A button shines instead of hiding
The dashboard states its time
Hop hop, the filters align

Comment @coderabbitai help to get the list of available commands.

@seefs001
seefs001 merged commit d1c79d7 into QuantumNous:main Sep 14, 2026
1 of 3 checks passed
stonegr pushed a commit to stonegr/new-api that referenced this pull request Sep 14, 2026
Javabcd pushed a commit to Javabcd/new-api that referenced this pull request Sep 16, 2026
kimberxu pushed a commit to kimberxu/new-api that referenced this pull request Sep 16, 2026
yang-yang9 added a commit to yyangTeam/new-api that referenced this pull request Sep 19, 2026
Fixes all failing PR #8 checks. All changes are CI-infra or fork-test-only;
no production/functional behavior changed.

CI infrastructure:
- web/package.json: add "routes:gen": "bunx @tanstack/router-cli generate"
  and de-duplicate the pre-existing duplicate "test"/"test:watch" keys
  (origin/dev already had both blocks; bun warned "Duplicate key").
- .github/workflows/ci.yml frontend job: add a "Generate route tree" step
  before typecheck (routeTree.gen.ts is gitignored, so a fresh CI checkout
  had no route tree and typecheck failed with route types resolving to
  never/undefined). Remove the redundant "bun run test" step: it ran the
  full vitest suite with no --maxWorkers and OOM'd (happy-dom); the 16-shard
  frontend-tests.yml already covers frontend testing comprehensively.

Stale fork coverage tests (aligned to upstream-merged behavior, test-only):
- models/index.test.tsx: drop assertions for routing fields relocated to
  request-policies (RetryTimes, channel_affinity_*).
- security/section-registry.test.tsx: upstream dropped the sensitive-words
  section (4->3 sections); update expected IDs/nav items.
- home/hero-terminal-demo.test.tsx: global test-setup mocks matchMedia to
  reduced-motion:matches, which early-returns the component so it never
  cycles to the /v1/responses demo; locally override matchMedia in that test.
- components/animate-in-view.test.tsx: same global matchMedia mock took the
  reduced-motion path (no opacity-0, no observer); override in beforeEach.
- dashboard/lib/filters.test.ts: upstream QuantumNous#7355 changed week default 30->29.
- pricing/model-details-uptime-sparkline.test.tsx: upstream QuantumNous#7418 changed
  overall% format 99.5%->99.50% (formatUptimePct toFixed(2)).

Verified locally: typecheck passes; the 6 fixed test files pass together
(57/57). routeTree.gen.ts stays gitignored; CI generates it via routes:gen.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
GuDong2003 pushed a commit to GuDong2003/new-api that referenced this pull request Sep 25, 2026
TomJKS pushed a commit to TomJKS/new-api that referenced this pull request Sep 28, 2026
timwenx pushed a commit to timwenx/new-api that referenced this pull request Nov 18, 2026
xiaolanawaqaq pushed a commit to xiaolanawaqaq/new-apiaaa that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 数据看板用户统计:周粒度下默认时间范围未选中

2 participants