9 Commits

Author SHA1 Message Date
356039d9cf feat: harden analytics dashboard 2026-05-27 15:19:31 +08:00
20d8b61aa3 feat: add user token breakdown data 2026-05-08 17:27:59 +08:00
ab915e9292 Add cost metrics to analytics dashboard 2026-04-28 11:27:51 +08:00
67e43b02bf perf: 添加查询缓存层,避免重复解析 JSON(TTL 2 分钟) 2026-04-22 10:05:19 +08:00
c5c91cc157 feat: 添加缓存 Token 独立展示(cache_creation / cache_read)
从 logs 表 other JSON 字段提取 cache_creation_tokens 和 cache_tokens,
在排名、日志、聚合、详情页分别展示,total_tokens 包含缓存部分。
2026-04-20 19:55:09 +08:00
c809ab16e6 fix: 修复排名页跳转用户详情数据为0的问题
排名页使用 display_name(中文名)作为链接参数,但详情查询用
username(英文)过滤,导致 SQL 匹配不到数据全部返回0。

- 排名 API 额外返回 username 字段
- 跳转链接改用 username 作为参数
- 详情 API 返回 display_name 用于页面标题展示
2026-04-08 20:08:08 +08:00
13805a47be fix: refactor time range to single source of truth with correct dates
- Default range changed from 30d to 7d
- Presets (today/7d/30d) now directly set customStart/customEnd dates,
  eliminating duplicate getTimeRange() calculation
- "All" preset fetches actual data boundaries from /api/date-range
  and backfills the custom date picker
- Clicking "custom" opens popover without triggering data refresh;
  only confirm applies changes
- SQL trend dates cast to ::text to avoid pg driver Date timezone offset
- Fix created_at filter from < to <= for end timestamp
2026-04-07 16:22:18 +08:00
35b8fec96c fix: use toISOString for trend date serialization to prevent year 2001 bug
pg driver returns PostgreSQL date as JS Date object. String(date).slice(0,10)
produced "Mon Apr 07" instead of "2026-04-07", causing chart tooltips to
default to year 2001 when parsed by new Date().
2026-04-07 15:50:30 +08:00
b719b358f8 feat: API analytics dashboard with i18n and theme support
Next.js full-stack analytics dashboard for new-api.
- Direct PostgreSQL readonly queries on logs table
- 5 pages: Dashboard, Rankings, Aggregation, Logs, Detail
- Dark/Light/System theme with CSS variables
- Chinese/English i18n (default Chinese)
- Recharts with dual Y-axis for input/output tokens
- Lucide icons + Motion animations
- Docker + docker-compose with external sinobridge network, port 8019
2026-04-02 12:47:50 +08:00