Wesley Liddick
9dcd3cd491
Merge pull request #754 from xvhuan/perf/admin-core-large-dataset
...
perf(admin): 优化后台大数据场景加载性能(仪表盘/用户/账号/Ops)
2026-03-04 15:15:13 +08:00
Wesley Liddick
49767cccd2
Merge pull request #755 from xvhuan/perf/admin-usage-fast-pagination-main
...
perf(admin-usage): 优化 usage 大表分页,默认避免全量 COUNT(*)
2026-03-04 14:15:57 +08:00
xvhuan
f6fe5b552d
fix(admin): resolve CI lint and user subscriptions regression
2026-03-04 14:07:17 +08:00
xvhuan
05b1c66aa8
perf(admin-usage): avoid expensive count on large usage_logs pagination
2026-03-04 13:51:27 +08:00
xvhuan
80ae592c23
perf(admin): optimize large-dataset loading for dashboard/users/accounts/ops
2026-03-04 13:45:49 +08:00
shaw
ba6de4c4d4
feat: /keys页面支持表单筛选
2026-03-04 11:29:31 +08:00
shaw
0aa3cf677a
chore: 清理一些无用的文件
2026-03-04 10:15:42 +08:00
shaw
4a91954532
fix: correct migration 061 checksum and add missing BillingCache mock methods
...
- Fix fileChecksum for 061 migration: use TrimSpace hash (66207e7a) instead
of raw sha256sum (97bdd9a3), matching the actual runtime computation
- Add 222b4a09 as accepted DB checksum for 061 migration
- Add missing GetAPIKeyRateLimit/SetAPIKeyRateLimit/UpdateAPIKeyRateLimitUsage/
InvalidateAPIKeyRateLimit methods to mock BillingCache in test stubs
- Fix NewBillingCacheService call in singleflight test (add apiKeyRepo param)
2026-03-03 16:11:05 +08:00
shaw
b8b5cec35c
fix: resolve CI lint errors and test compilation failures for rate limit feature
...
- Fix errcheck: properly handle rows.Close() error via named return + defer closure
- Fix gofmt: auto-format billing_cache.go, api_key_service.go, billing_cache_service.go
- Add missing rate limit interface methods to 4 test stubs (GetRateLimitData, IncrementRateLimitUsage, ResetRateLimitWindows)
- Fix NewBillingCacheService calls missing the new apiKeyRepo parameter
2026-03-03 15:43:08 +08:00
Wesley Liddick
43c203333e
Merge pull request #733 from DaydreamCoding/fix/group-isolation
...
fix(gateway): 分组隔离 — 禁止未分组账号被跨组调度
2026-03-03 15:10:30 +08:00
Wesley Liddick
1c6393b131
Merge pull request #732 from xvhuan/perf/admin-dashboard-preagg
...
perf(admin): 优化 Dashboard 大数据量加载(预聚合趋势+异步用户趋势)
2026-03-03 15:10:20 +08:00
Wesley Liddick
22f04e72e5
Merge pull request #731 from xvhuan/fix/061-bounded-backfill-startup
...
fix(migrations): 061 迁移改为限时分批回填,避免启动阻塞导致 502
2026-03-03 15:08:18 +08:00
shaw
a80ec5d8bb
feat: apikey支持5h/1d/7d速率控制
2026-03-03 15:01:10 +08:00
QTom
530a16291c
fix(gateway): 分组隔离 — 禁止未分组账号被跨组调度
...
当 API Key 无分组时,调度仅从未分组账号池中选取。
修复 isAccountInGroup 在 groupID==nil 时的逻辑,
同时补全 scheduler_snapshot_service 和 gemini_compat_service
中的 SimpleMode 保护,确保分组隔离在所有调度路径生效。
新增 ListSchedulableUngroupedByPlatform/s 方法,
使用 Ent 的 Not(HasAccountGroups()) 谓词实现未分组账号隔离。
新增 17 个单元和端到端隔离测试,覆盖所有分支和边界条件。
2026-03-03 13:20:58 +08:00
xvhuan
7be8f4dc6e
perf(admin-dashboard): accelerate trend load with pre-aggregation and async user trend
2026-03-03 11:53:54 +08:00
ius
99f1e3ff35
fix(migrations): avoid startup outage from 061 full-table backfill
2026-03-03 11:01:22 +08:00
QTom
a9285b8a94
feat(gateway): 双模式用户消息队列 — 串行队列 + 软性限速
...
新增 UMQ (User Message Queue) 双模式支持:
- serialize: 账号级分布式串行锁 + RPM 自适应延迟(严格限流)
- throttle: 仅 RPM 自适应前置延迟,不阻塞并发(软性限速)
后端:
- config: 新增 Mode 字段,保留 Enabled 向后兼容
- service: 新增 UserMessageQueueService(Lua 锁/延迟算法/清理 worker)
- repository: 新增 UserMsgQueueCache(Redis Lua acquire/release/force-release)
- handler: 新增 UserMsgQueueHelper(SSE ping + 等待循环 + throttle)
- gateway: 按 mode 分支集成 serialize/throttle 逻辑
- lint: 修复 gofmt rewrite rules、errcheck 类型断言、staticcheck QF1012
前端:
- 三态选择器 UI(关闭/软性限速/串行队列)替代 toggle 开关
- BulkEdit 支持 null 语义(不修改)
- i18n 中英文文案
通过 6 轮专家评审(42 次 review)、golangci-lint、单元测试、集成测试。
2026-03-03 01:05:11 +08:00
QTom
fdcbf7aacf
feat(proxy): 集中代理 URL 验证并实现全局 fail-fast
...
提取 proxyurl.Parse() 公共包,将分散在 6 处的代理 URL 验证逻辑
统一收敛,确保无效代理配置在创建时立即失败,永不静默回退直连。
主要变更:
- 新增 proxyurl 包:统一 TrimSpace → url.Parse → Host 校验 → Scheme 白名单
- socks5:// 自动升级为 socks5h://,防止 DNS 泄漏(大小写不敏感)
- antigravity: http.ProxyURL → proxyutil.ConfigureTransportProxy 支持 SOCKS5
- openai_oauth: 删除 newOpenAIOAuthHTTPClient,收编至 httpclient.GetClient
- 移除未使用的 ProxyStrict 字段(fail-fast 已是全局默认行为)
- 补充 15 个 proxyurl 测试 + pricing/usage fail-fast 测试
2026-03-02 16:04:20 +08:00
QTom
d869ac95fa
feat(identity): 指纹缓存 TTL 懒续期机制
...
- TTL 改为 7 天,配合 24 小时自动续期保持活跃账号永不过期
- 版本升级时采用合并语义,仅更新请求中实际存在的字段
- 添加产品名验证防止浏览器 UA 误判为更新版本
2026-03-02 01:12:41 +08:00
erio
65459a99b6
feat(dashboard): add group usage distribution chart to usage page
...
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)
2026-03-01 20:10:51 +08:00
Gemini Wen
c6e26c5a16
fix(group): clear nullable limit fields on update
2026-03-01 18:46:38 +08:00
Wesley Liddick
9fd95df5cf
Merge pull request #679 from DaydreamCoding/feat/account-rpm-limit
...
feat: 添加账号级别 RPM(每分钟请求数)限流功能
2026-02-28 22:37:10 +08:00
QTom
115d06edf0
fix: 修复 gofmt 格式问题
2026-02-28 20:38:35 +08:00
QTom
607237571f
fix: address code review issues for RPM limiting feature
...
- Use TxPipeline (MULTI/EXEC) instead of Pipeline for atomic INCR+EXPIRE
- Filter negative values in GetBaseRPM(), update test expectation
- Add RPM batch query (GetRPMBatch) to account List API
- Add warn logs for RPM increment failures in gateway handler
- Reset enableRpmLimit on BulkEditAccountModal close
- Use union type 'tiered' | 'sticky_exempt' for rpmStrategy refs
- Add design decision comments for rdb.Time() RTT trade-off
2026-02-28 20:37:37 +08:00
QTom
c1c31ed9b2
feat: wire RPMCache into GatewayService and AccountHandler
2026-02-28 20:35:38 +08:00
QTom
777be05348
feat: add RPMCache interface and Redis implementation with Lua scripts
2026-02-28 20:34:22 +08:00
QTom
9a91815b94
feat(admin): 完整实现管理员修改用户 API Key 分组的功能
...
## 核心功能
- 添加 AdminUpdateAPIKeyGroupID 服务方法,支持绑定/解绑/保持不变三态语义
- 实现 UserRepository.AddGroupToAllowedGroups 接口,自动同步专属分组权限
- 添加 HTTP PUT /api-keys/:id handler 端点,支持管理员直接修改 API Key 分组
## 事务一致性
- 使用 ent Tx 保证专属分组绑定时「添加权限」和「更新 Key」的原子性
- Repository 方法支持 clientFromContext,兼容事务内调用
- 事务失败时自动回滚,避免权限孤立
## 业务逻辑
- 订阅类型分组阻断,需通过订阅管理流程
- 非活跃分组拒绝绑定
- 负 ID 和非法 ID 验证
- 自动授权响应,告知管理员成功授权的分组
## 代码质量
- 16 个单元测试覆盖所有业务路径和边界用例
- 7 个 handler 集成测试覆盖 HTTP 层
- GroupRepo stub 返回克隆副本,防止测试间数据泄漏
- API 类型安全修复(PaginatedResponse<ApiKey>)
- 前端 ref 回调类型对齐 Vue 规范
## 国际化支持
- 中英文提示信息完整
- 自动授权成功/失败提示
2026-02-28 20:18:14 +08:00
yangjianbo
bb664d9bbf
feat(sync): full code sync from release
2026-02-28 15:01:20 +08:00
shaw
c75c6b6858
fix: 将 DriveClient 注入 GeminiOAuthService,消除单元测试中的真实 HTTP 调用
...
FetchGoogleOneTier 原先在方法内部直接创建 DriveClient 实例,
导致单元测试中对 googleapis.com 发起真实 HTTP 请求,在 CI 环境
产生 401 错误。
将 DriveClient 作为依赖注入到 GeminiOAuthService,遵循项目
端口与适配器架构规范:
- 新增 repository/gemini_drive_client.go 作为 Provider
- 注册到 repository Wire ProviderSet
- 测试中使用 mockDriveClient 替代真实调用
2026-02-26 10:53:04 +08:00
shaw
492b852a1f
fix: 幂等测试使用哈希值避免超出 VARCHAR(64) 限制
...
idempotency_key_hash 和 request_fingerprint 列为 VARCHAR(64),
而 uniqueTestValue 生成的字符串含完整测试名可能超过 64 字符。
新增 hashedTestValue 辅助函数对测试值做 SHA-256 哈希,
与生产逻辑一致且严格符合列宽限制。
2026-02-24 12:18:07 +08:00
shaw
8a137405d4
fix: 移除重复的 ptrTime 函数声明修复编译错误
...
idempotency_repo_integration_test.go 中的 ptrTime 与
scheduler_cache.go 中的声明冲突,导致 repository 包测试构建失败。
2026-02-24 11:49:01 +08:00
yangjianbo
5fa45f3b8c
feat(idempotency): 为关键写接口接入幂等并完善并发容错
2026-02-23 12:45:37 +08:00
yangjianbo
7be1195281
feat(api-key): 增加 API Key 上次使用时间并补齐测试
2026-02-22 22:07:17 +08:00
yangjianbo
a89477ddf5
perf(gateway): 优化热点路径并补齐高覆盖测试
2026-02-22 13:31:30 +08:00
yangjianbo
900cce20a1
feat(sora): 对齐 Sora OAuth 流程并隔离网关请求路径
...
- 新增并接通 Sora 专用 OAuth 接口与 ST/RT 换取能力
- 完成前端 Sora 授权、RT/ST 手动导入与账号创建流程
- 强化 Sora token 恢复、转发日志与网关路由隔离行为
- 补充后端服务层与路由层相关测试覆盖
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-19 08:02:56 +08:00
yangjianbo
5d9667d27a
Merge branch 'main' into test
...
# Conflicts:
# backend/cmd/server/VERSION
# backend/ent/migrate/schema.go
# backend/ent/mutation.go
# backend/ent/runtime/runtime.go
# backend/ent/usagelog.go
# backend/ent/usagelog/usagelog.go
# backend/ent/usagelog/where.go
# backend/ent/usagelog_create.go
# backend/ent/usagelog_update.go
# backend/internal/repository/usage_log_repo.go
# backend/internal/server/api_contract_test.go
# backend/internal/server/middleware/cors.go
# backend/internal/service/gateway_service.go
2026-02-18 20:16:31 +08:00
yangjianbo
fad04ca995
Merge branch 'main' of https://github.com/mt21625457/aicodex2api
2026-02-18 20:10:32 +08:00
John Doe
3d1f03c286
feat: add Cache TTL Override per account + bump VERSION to 0.1.83
...
- Account-level cache TTL override: rewrite Anthropic cache_creation
token classification (5m↔1h) in streaming/non-streaming responses
- New DB field cache_ttl_overridden in usage_log for billing tracking
- Migration 055_add_cache_ttl_overridden
- Frontend: CacheTTL override toggle in account create/edit modals
- Ent schema regenerated for new usage_log fields
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-02-17 14:19:24 +03:00
yangjianbo
41d0383fb7
merge(test): 合并 main 并解决前端筛选器冲突
2026-02-15 22:04:06 +08:00
程序猿MT
1cf51b14f7
Merge branch 'Wei-Shaw:main' into main
2026-02-15 20:49:14 +08:00
yangjianbo
d04b47b3ca
feat(backend): 提交后端审计修复与配套测试改动
2026-02-14 11:23:10 +08:00
yangjianbo
862199143e
fix(ops): 修复错误日志查询 q 过滤列名二义性
2026-02-14 11:21:30 +08:00
yangjianbo
abf5de69fb
Merge branch 'main' into test
2026-02-12 23:43:47 +08:00
程序猿MT
174d7c774d
Merge branch 'Wei-Shaw:main' into main
2026-02-12 23:12:41 +08:00
yangjianbo
584cfc3db2
chore(logging): 完成后端日志审计与结构化迁移
...
- 将高密度服务与处理器日志迁移到新日志系统(LegacyPrintf/结构化日志)
- 增加 stdlog bridge 与兼容测试,保留旧日志捕获能力
- 将 OpenAI 断流告警改为结构化 Warn 并改造对应测试为 sink 捕获
- 补齐后端相关文件 logger 引用并通过全量 go test
2026-02-12 19:01:09 +08:00
yangjianbo
fff1d54858
feat(log): 落地统一日志底座与系统日志运维能力
2026-02-12 16:27:29 +08:00
yangjianbo
af3069073a
chore(lint): 修复 golangci-lint unused
...
- 移除 OpenAIGatewayHandler 未使用字段
- 删除并发缓存中未使用的 Redis 脚本常量
- 将仅供 unit 测试使用的 parseIntegralNumber 移入 unit build tag 文件
2026-02-12 14:20:56 +08:00
yangjianbo
65661f24e2
feat(ops): 运维监控新增 OpenAI Token 请求统计表
...
- 新增管理端接口 /api/v1/admin/ops/dashboard/openai-token-stats,按模型聚合统计 gpt% 请求
- 支持 time_range=30m|1h|1d|15d|30d(默认 30d),支持 platform/group_id 过滤
- 支持分页(page/page_size)或 TopN(top_n)互斥查询
- 前端运维监控页新增统计表卡片,包含空态/错误态与分页/TopN 交互
- 补齐后端与前端测试
2026-02-12 14:20:14 +08:00
yangjianbo
114e172603
test(repository): 补充 JWT 密钥引导并发与兼容性单测
2026-02-12 12:07:20 +08:00
yangjianbo
09c8380b3d
fix(repository): 修复 JWT 密钥引导冲突一致性与并发读取竞态
2026-02-12 12:04:13 +08:00