1. 17 Mar, 2026 1 commit
    • Ethan0x0000's avatar
      feat(dashboard): add model source dimension to stats queries · 7134266a
      Ethan0x0000 authored
      Support querying model statistics by 'requested', 'upstream', or 'mapping' dimension. Add resolveModelDimensionExpression for safe SQL expression generation, IsValidModelSource whitelist validator, and NormalizeModelSource fallback. Repository persists and scans upstream_model in all insert/select paths.
      7134266a
  2. 16 Mar, 2026 1 commit
    • erio's avatar
      feat(dashboard): add per-user drill-down for group, model, and endpoint distributions · 4b41e898
      erio authored
      Click on a group name, model name, or endpoint name in the distribution
      tables to expand and show per-user usage breakdown (requests, tokens,
      actual cost, standard cost).
      
      Backend: new GET /admin/dashboard/user-breakdown API with group_id,
      model, endpoint, endpoint_type filters.
      Frontend: clickable rows with expand/collapse sub-table in all three
      distribution charts.
      4b41e898
  3. 15 Mar, 2026 3 commits
  4. 12 Mar, 2026 6 commits
  5. 11 Mar, 2026 1 commit
  6. 09 Mar, 2026 1 commit
  7. 05 Mar, 2026 1 commit
  8. 04 Mar, 2026 1 commit
  9. 03 Mar, 2026 1 commit
  10. 01 Mar, 2026 1 commit
    • erio's avatar
      feat(dashboard): add group usage distribution chart to usage page · 65459a99
      erio authored
      Add a doughnut chart showing usage statistics broken down by group on
      the admin usage records page. The chart appears alongside the existing
      model distribution chart (2-column grid), with the token usage trend
      chart moved to a separate full-width row below.
      
      Changes:
      - backend/pkg/usagestats: add GroupStat type
      - backend/service: add GetGroupStatsWithFilters interface method and implementation
      - backend/repository: implement GetGroupStatsWithFilters with LEFT JOIN groups
      - backend/handler: add GetGroupStats handler with full filter support
      - backend/routes: register GET /admin/dashboard/groups route
      - backend/tests: add GetGroupStatsWithFilters stubs to contract/sora tests
      - frontend/types: add GroupStat interface
      - frontend/api: add getGroupStats API function and types
      - frontend/components: add GroupDistributionChart.vue doughnut chart
      - frontend/views: update UsageView layout and load group stats in parallel
      - frontend/i18n: add groupDistribution, group, noGroup keys (zh + en)
      65459a99
  11. 28 Feb, 2026 1 commit
  12. 22 Feb, 2026 1 commit
  13. 17 Feb, 2026 1 commit
  14. 07 Feb, 2026 1 commit
    • yangjianbo's avatar
      fix(audit): 第二批审计修复 — P0 生产 Bug、安全加固、性能优化、缓存一致性、代码质量 · 2588fa6a
      yangjianbo authored
      
      
      基于 backend-code-audit 审计报告,修复剩余 P0/P1/P2 共 34 项问题:
      
      P0 生产 Bug:
      - 修复 time.Since(time.Now()) 计时逻辑错误 (P0-03)
      - generateRandomID 改用 crypto/rand 替代固定索引 (P0-04)
      - IncrementQuotaUsed 重写为 Ent 原子操作消除 TOCTOU 竞态 (P0-05)
      
      安全加固:
      - gateway/openai handler 错误响应替换为泛化消息,防止内部信息泄露 (P1-14)
      - usage_log_repo dateFormat 参数改用白名单映射,防止 SQL 注入 (P1-16)
      - 默认配置安全加固:sslmode=prefer、response_headers=true、mode=release (P1-18/19, P2-15)
      
      性能优化:
      - gateway handler 循环内 defer 替换为显式 releaseWait 闭包 (P1-02)
      - group_repo/promo_code_repo Count 前 Clone 查询避免状态污染 (P1-03)
      - usage_log_repo 四个查询添加 LIMIT 10000 防止 OOM (P1-07)
      - GetBatchUsageStats 添加时间范围参数,默认最近 30 天 (P1-10)
      - ip.go CIDR 预编译为包级变量 (P1-11)
      - BatchUpdateCredentials 重构为先验证后更新 (P1-13)
      
      缓存一致性:
      - billing_cache 添加 jitteredTTL 防止缓存雪崩 (P2-10)
      - DeductUserBalance/UpdateSubscriptionUsage 错误传播修复 (P2-12)
      - UserService.UpdateBalance 成功后异步失效 billingCache (P2-13)
      
      代码质量:
      - search 截断改为按 rune 处理,支持多字节字符 (P2-01)
      - TLS Handshake 改为 HandshakeContext 支持 context 取消 (P2-07)
      - CORS 预检添加 Access-Control-Max-Age: 86400 (P2-16)
      
      测试覆盖:
      - 新增 user_service_test.go(UpdateBalance 缓存失效 6 个用例)
      - 新增 batch_update_credentials_test.go(fail-fast + 类型验证 7 个用例)
      - 新增 response_transformer_test.go、ip_test.go、usage_log_repo_unit_test.go、search_truncate_test.go
      - 集成测试:IncrementQuotaUsed 并发测试、billing_cache 错误传播测试
      - config_test.go 补充 server.mode/sslmode 默认值断言
      Co-Authored-By: default avatarClaude Opus 4.6 <noreply@anthropic.com>
      2588fa6a
  15. 05 Feb, 2026 1 commit
    • JIA-ss's avatar
      feat(gateway): filter /v1/usage stats by API Key instead of UserID · fa3ea5ee
      JIA-ss authored
      
      
      Previously the /v1/usage endpoint aggregated usage stats (today/total
      tokens, cost, RPM/TPM) across all API Keys belonging to the user.
      This made it impossible to distinguish usage from different API Keys
      (e.g. balance vs subscription keys).
      
      Now the usage stats are filtered by the current request's API Key ID,
      so each key only sees its own usage data. The balance/remaining fields
      are unaffected and still reflect the user-level wallet balance.
      
      Changes:
      - Add GetAPIKeyDashboardStats to repository interface and implementation
      - Add getPerformanceStatsByAPIKey helper (also fixes TPM to include
        cache_creation_tokens and cache_read_tokens)
      - Add GetAPIKeyDashboardStats to UsageService
      - Update Usage handler to call GetAPIKeyDashboardStats(apiKey.ID)
      Co-Authored-By: default avatarClaude Opus 4.5 <noreply@anthropic.com>
      fa3ea5ee
  16. 03 Feb, 2026 1 commit
  17. 02 Feb, 2026 1 commit
  18. 31 Jan, 2026 1 commit
  19. 18 Jan, 2026 1 commit
  20. 15 Jan, 2026 3 commits
  21. 14 Jan, 2026 2 commits
    • longgexx's avatar
      fix(admin): 修复使用记录页面趋势图筛选联动和日期选择问题 · 806f402b
      longgexx authored
         修复两个问题:
         1. Token使用趋势图和模型分布图未响应筛选条件
         2. 上午时段选择今天刷新后日期回退到前一天
      
         前端修改:
         - 更新 dashboard API 类型定义,添加 model、account_id、group_id、stream 参数支持
         - 修改 UsageView 趋势图加载逻辑,传递所有筛选参数到后端
         - 修复日期格式化函数,使用本地时区避免 UTC 转换导致的日期偏移
      
         后端修改:
         - Handler 层:接收并解析所有筛选参数(model、account_id、group_id、stream)
         - Service 层:传递完整的筛选参数到 Repository 层
         - Repository 层:SQL 查询动态添加所有过滤条件
         - 更新接口定义和所有调用点以保持一致性
      
         影响范围:
         - /admin/dashboard/trend 端点现支持完整筛选
         - /admin/dashboard/models 端点现支持完整筛选
         - 用户在后台使用记录页面选择任意筛选条件时,趋势图和模型分布图会实时响应
         - 日期选择器在任何时区下都能正确保持今天的选择
      806f402b
    • 墨颜's avatar
      feat(计费): 支持账号计费倍率快照与统计展示 · fb99ceac
      墨颜 authored
      - 新增 accounts.rate_multiplier(默认 1.0,允许 0)
      - 使用 usage_logs.account_rate_multiplier 记录倍率快照,避免历史回算
      - 统计/导出/管理端展示账号口径费用(total_cost * account_rate_multiplier)
      fb99ceac
  22. 11 Jan, 2026 2 commits
  23. 09 Jan, 2026 2 commits
    • Edric.Li's avatar
      feat(api-key): 添加 IP 白名单/黑名单限制功能 (#221) · 0a4641c2
      Edric.Li authored
      * feat(api-key): add IP whitelist/blacklist restriction and usage log IP tracking
      
      - Add IP restriction feature for API keys (whitelist/blacklist with CIDR support)
      - Add IP address logging to usage logs (admin-only visibility)
      - Remove billing_type column from usage logs UI (redundant)
      - Use generic "Access denied" error message for security
      
      Backend:
      - New ip package with IP/CIDR validation and matching utilities
      - Database migrations for ip_whitelist, ip_blacklist (api_keys) and ip_address (usage_logs)
      - Middleware IP restriction check after API key validation
      - Input validation for IP/CIDR patterns on create/update
      
      Frontend:
      - API key form with enable toggle for IP restriction
      - Shield icon indicator in table for keys with IP restriction
      - Removed billing_type filter and column from usage views
      
      * fix: update API contract tests for ip_whitelist/ip_blacklist fields
      
      Add ip_whitelist and ip_blacklist fields to expected JSON responses
      in API contract tests to match the new API key schema.
      0a4641c2
    • Edric Li's avatar
      feat(api-key): add IP whitelist/blacklist restriction and usage log IP tracking · 90798f14
      Edric Li authored
      - Add IP restriction feature for API keys (whitelist/blacklist with CIDR support)
      - Add IP address logging to usage logs (admin-only visibility)
      - Remove billing_type column from usage logs UI (redundant)
      - Use generic "Access denied" error message for security
      
      Backend:
      - New ip package with IP/CIDR validation and matching utilities
      - Database migrations for ip_whitelist, ip_blacklist (api_keys) and ip_address (usage_logs)
      - Middleware IP restriction check after API key validation
      - Input validation for IP/CIDR patterns on create/update
      
      Frontend:
      - API key form with enable toggle for IP restriction
      - Shield icon indicator in table for keys with IP restriction
      - Removed billing_type filter and column from usage views
      90798f14
  24. 07 Jan, 2026 1 commit
    • Edric Li's avatar
      feat(usage-log): 增加请求 User-Agent 记录 · 1ada6cf7
      Edric Li authored
      在使用记录中添加 user_agent 字段,用于记录 API 请求的 User-Agent 头信息,
      便于分析客户端类型和调试。
      
      变更内容:
      - 新增数据库迁移 028_add_usage_logs_user_agent.sql
      - 更新 UsageLog 模型和 Ent Schema 添加 user_agent 字段
      - 更新 Repository 层的 Create 和 scanUsageLog 方法
      - 更新 RecordUsageInput 结构体支持传入 UserAgent
      - 更新 Claude/OpenAI/Gemini 三个网关 Handler 传递 UserAgent
      
      🤖 Generated with [Claude Code](https://claude.com/claude-code
      
      )
      Co-Authored-By: default avatarClaude Opus 4.5 <noreply@anthropic.com>
      1ada6cf7
  25. 06 Jan, 2026 1 commit
    • shaw's avatar
      feat(admin/usage): 优化管理员用量页面功能和体验 · 015974a2
      shaw authored
      后端改进:
      - 新增 GetStatsWithFilters 方法支持完整筛选条件
      - Stats 端点支持 account_id, group_id, model, stream, billing_type 参数
      - 统一使用 filters 结构体,移除冗余的分支逻辑
      
      前端改进:
      - 统计卡片添加"所选范围内"文字提示
      - 优化总消费显示格式,清晰展示实际费用和标准计费
      - Token 和费用列添加问号图标 tooltip 显示详细信息
      - API Key 搜索框体验优化:点击即显示下拉选项
      - 选择用户后自动加载该用户的所有 API Key
      015974a2
  26. 05 Jan, 2026 1 commit
    • song's avatar
      feat: 图片生成计费功能 · d4c2b723
      song authored
      - 新增 Group 图片价格配置(image_price_1k/2k/4k)
      - BillingService 新增 CalculateImageCost 方法
      - AntigravityGatewayService 支持识别图片生成模型并按次计费
      - UsageLog 新增 image_count 和 image_size 字段
      - 前端分组管理支持配置图片价格(antigravity 和 gemini 平台)
      - 图片计费复用通用计费能力(余额检查、扣费、倍率、订阅限额)
      d4c2b723
  27. 04 Jan, 2026 2 commits
    • IanShaw027's avatar
      fix(lint): 修复所有 Go 命名规范问题 · a4953785
      IanShaw027 authored
      - 全局替换 ApiKey → APIKey(类型、字段、方法、变量)
      - 修复所有 initialism 命名(API, SMTP, HTML, URL 等)
      - 添加所有缺失的包注释
      - 修复导出符号的注释格式
      
      主要修改:
      - ApiKey → APIKey(所有出现的地方)
      - ApiKeyID → APIKeyID
      - ApiKeyIDs → APIKeyIDs
      - TestSmtpConnection → TestSMTPConnection
      - HtmlURL → HTMLURL
      - 添加 20+ 个包注释
      - 修复 10+ 个导出符号注释格式
      
      验证结果:
      - ✓ golangci-lint: 0 issues
      - ✓ 单元测试: 通过
      - ✓ 集成测试: 通过
      a4953785
    • ianshaw's avatar
      fix(usage): 使用日志事务和幂等性修复 · 71bf5b9e
      ianshaw authored
      - UsageLogRepository.Create 返回 inserted 标志
      - UsageService 使用事务保证原子性
      - 避免重复扣费(幂等重试场景)
      - 更新依赖注入和测试
      71bf5b9e