Skip to content

z.ai: add 7-day / 30-day ranges to the model-usage chart (needs a daily-granularity fetch) #2523

Description

@LeoLin990405

Summary

The z.ai Hourly Usage chart (from api/monitor/usage/model-usage) currently offers Today and 24h ranges (hourly bars). The BigModel/z.ai dashboard also offers 近7天 / 近30天 (7-day / 30-day) views. This proposes adding 7-day and 30-day ranges to CodexBar's chart.

Key finding (affects the implementation shape)

The model-usage endpoint returns granularity by span:

  • short window (≈1 day) → hourly buckets, xTime like "2026-07-31 14:00";
  • 30-day window → daily buckets, xTime like "2026-07-01" (verified live: startTime=2026-07-02 00:00:00&endTime=2026-07-31 23:59:59 → 31 daily points).

So 7d/30d cannot be derived from the existing 1-day/hourly snapshot data — they need a separate daily-granularity fetch (a wider startTime/endTime), and the chart needs to render daily bars (date labels) for those ranges alongside the existing hourly bars.

Proposed shape

  • Add a second, daily model-usage fetch (e.g. last 30 days) into the z.ai snapshot, alongside the existing hourly (1-day) fetch.
  • Extend ZaiHourlyRange with .last7d / .last30d; render daily bars (parse "yyyy-MM-dd", label MM-dd) for those, hourly bars for Today/24h.
  • Add the two range tabs to ZaiHourlyUsageChartMenuView.
  • Tests for the daily parse/aggregation + range filtering.

Cost: one extra model-usage request per refresh (the daily window). No new endpoint or auth.

I'll send a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions