Skip to content

feat(usage): date-range filter and Excel export for token stats - #599

Open
huangcheng wants to merge 5 commits into
TencentCloud:developfrom
huangcheng:feature/token-usage-day-month-export
Open

feat(usage): date-range filter and Excel export for token stats#599
huangcheng wants to merge 5 commits into
TencentCloud:developfrom
huangcheng:feature/token-usage-day-month-export

Conversation

@huangcheng

@huangcheng huangcheng commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Token Usage page: RangePicker (presets + custom range), expert/user filters, and disable dates after today
  • Add /api/usage/export.xlsx and /api/admin/usage/export.xlsx with detail + by-day/expert/model sheets, localized headers, charts, and report styling
  • Detail sheet defaults to ascending timestamps (oldest → newest); export filename is Token用量_YYYY-MM-DD-YYYY-MM-DD.xlsx / token-usage_…xlsx by locale

Fixes #154

Test plan

  • uv run pytest tests/unit/db/test_usage_window.py tests/integration/test_usage_api.py -q
  • Dashboard Token Usage: presets/custom range, expert, and user filters update charts/tables
  • Export Excel: zh/en filenames and sheet headers match Accept-Language; detail times are YYYY-MM-DD HH:mm:ss (no offset), ascending
  • RangePicker cannot select dates after today; clear range returns to all-time

Add RangePicker presets/custom ranges, multi-sheet Excel export with
localized headers and charts, and filter coverage for TencentCloud#154.
Keep the newest N rows when truncating, then reverse so Excel opens
oldest-first for chronological reading.
@huangcheng huangcheng changed the title feat(usage): Token 统计日期筛选与 Excel 导出 feat(usage): date-range filter and Excel export for token stats Sep 7, 2026
Order detail rows with a newest-N subquery then ts ASC so Excel opens
oldest-first; restart-sensitive Python reverse was easy to miss.
Keep Unreleased token-usage export notes and develop's shared-skill /
KB editor fixes.
Leave a blank spacer above the SUM TOTAL so Excel contiguous Sort
does not move 合计 with the filtered detail rows.
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.

1 participant