hailin
286e6aad01
fix(db): 添加缺失的数据库迁移文件
...
问题:
- wallet-service schema 中有 version 字段,但迁移文件中缺失
- presence-service 缺少初始化迁移文件
修复:
- wallet-service: 添加 20241216000000_add_version_column 迁移
- presence-service: 添加 20241204000000_init 初始化迁移(包含 version 字段)
- presence-service: 删除无效的 20251215100000 迁移(依赖不存在的表)
验证所有服务 schema 与 migration 一致性:
- identity-service: ✅ OK
- wallet-service: ✅ 已修复
- blockchain-service: ✅ OK (无 version 字段)
- planting-service: ✅ OK
- reward-service: ✅ OK
- referral-service: ✅ OK
- leaderboard-service: ✅ OK
- presence-service: ✅ 已修复
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-15 21:53:31 -08:00
hailin
cc06638e0e
feat(telemetry): 将userId改为userSerialNum字符串格式并完善遥测追踪
...
Backend (presence-service):
- 将EventLog.userId从BigInt改为String类型,存储userSerialNum(如D25121400005)
- 更新Prisma schema,userId字段改为VarChar(20)并添加索引
- 更新心跳相关命令和事件,统一使用userSerialNum字符串
- 添加数据库迁移文件
- 更新相关单元测试和集成测试
Frontend (mobile-app):
- TelemetryEvent新增toServerJson()方法,格式化为后端API期望的格式
- AccountService登录/恢复时设置TelemetryService的userId
- MultiAccountService切换账号时同步更新TelemetryService的userId
- 退出登录时清除TelemetryService的userId
- AuthProvider初始化时设置userId
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-15 06:55:25 -08:00
hailin
0c00382a98
fix: convert deploy.sh CRLF to LF and add executable permission
...
- Convert Windows CRLF line endings to Unix LF for all deploy.sh files
- Add executable permission to all deploy.sh scripts
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 07:01:13 -08:00
hailin
dba9d16074
.
2025-12-07 00:40:19 -08:00
hailin
6451cd6fc3
refactor: unify docker-compose configs to use shared infrastructure
...
All microservices now use the shared rwa-network and connect to:
- rwa-postgres: Shared PostgreSQL database server
- rwa-redis: Shared Redis cache
- rwa-kafka: Shared Kafka message broker
Each service's docker-compose.yml now only defines the application
container and uses `networks: external: true` to connect to the
shared infrastructure defined in the root docker-compose.yml.
This prevents duplicate infrastructure containers and ensures all
services can communicate via Kafka and share the same Redis/PostgreSQL.
Services updated:
- admin-service
- backup-service
- blockchain-service
- identity-service
- leaderboard-service
- mpc-service
- presence-service
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 00:35:56 -08:00
hailin
747e4ae8ef
refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing
...
- Remove Address field from PartyEndpoint (parties connect to router themselves)
- Update K8s Discovery to only manage PartyID and Role labels
- Add Party registration and SessionEvent protobuf definitions
- Implement PartyRegistry and SessionEventBroadcaster domain logic
- Add RegisterParty and SubscribeSessionEvents gRPC handlers
- Prepare infrastructure for party-driven MPC coordination
This is the first phase of migrating from coordinator-driven to party-driven
architecture following international MPC system design patterns.
2025-12-05 08:11:28 -08:00
Developer
9898665506
feat(all-services): 添加数据库自动迁移到所有服务启动流程
...
在每个服务的 Dockerfile 中添加启动脚本:
- 服务启动前先执行 prisma migrate deploy
- 如果迁移失败则回退到 prisma db push
- 确保数据库表在服务启动时自动创建
修改的服务:
- identity-service
- wallet-service
- backup-service
- planting-service
- referral-service
- reward-service
- leaderboard-service
- reporting-service
- authorization-service
- admin-service
- presence-service
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 01:50:01 -08:00
Developer
f771dc8f6e
fix(presence-service): 修复 MetricsModule 依赖注入,直接提供仓库实现
...
MetricsCollectorService 需要 DAU 和 EventLog 仓库,
但这些在 InfrastructureModule 中通过符号注入,
导致循环依赖问题。改为在 MetricsModule 中直接提供这些依赖。
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 01:35:59 -08:00
Developer
8faaedaa64
fix(presence-service): MetricsModule 导入 RedisModule 和 PersistenceModule
...
修复依赖注入错误: PresenceRedisRepository 和 DAU/EventLog 仓库无法解析
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 01:30:08 -08:00
Developer
43e769437f
fix(presence-service): 修复方法名 findByDay -> findByDate
...
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 00:53:04 -08:00
Developer
246c25ab8a
fix(presence-service): 同步 package-lock.json
...
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 00:05:46 -08:00
Developer
db8350b2f5
fix(identity-service): 更换 npm 镜像为华为云解决超时问题
...
- npmmirror CDN 超时 (EIDLETIMEOUT)
- 改用 mirrors.huaweicloud.com/repository/npm/
- 添加 disturl 配置加速 node 二进制下载
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 18:45:18 -08:00
Developer
9656a6f4c4
feat(presence-service): 添加 Prometheus 指标监控和 Grafana Dashboard
...
Prometheus 指标端点 (/api/v1/metrics):
- presence_online_users_total: 实时在线人数
- presence_dau_total: 今日 DAU
- presence_heartbeat_total: 心跳计数
- presence_events_received_total: 事件上报计数
- presence_session_start_total: 会话开始计数
- presence_heartbeat_duration_seconds: 心跳处理延迟
- presence_event_batch_duration_seconds: 事件批处理延迟
Grafana Dashboard:
- 核心指标概览 (在线人数、DAU、心跳、事件)
- 趋势图表 (在线人数趋势、心跳/事件速率)
- 事件分布 (饼图、按小时趋势)
- 性能指标 (P50/P95/P99 延迟)
- 服务资源 (内存、CPU)
配置更新:
- prometheus.yml 添加 presence-service 抓取配置
- package.json 添加 prom-client 依赖
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 08:38:05 -08:00
Developer
aa06607c1d
feat(presence-service): 添加 init-db 命令创建数据库
...
- 添加 init-db 命令自动创建 rwa_presence 数据库
- 创建数据库后自动运行 prisma db push 创建表结构
- 更新帮助文档
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 22:53:49 -08:00
Developer
fcd97f26cf
fix(presence-service): 添加 --no-deps 避免重启已运行的基础设施
...
deploy.sh start/up 命令添加 --no-deps 选项,防止在启动
presence-service 时重新创建已经运行的共享基础设施容器
(postgres, redis, kafka)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 22:19:40 -08:00
Developer
086d82f98a
feat(admin-service): 添加 init-db 命令自动创建数据库
...
用法: ./deploy.sh init-db
- 自动创建 rwa_admin 数据库(如不存在)
- 自动运行 Prisma 迁移
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 22:02:41 -08:00
Developer
c3f4243e81
fix(presence-service): 修复 deploy.sh 自调用权限问题
...
使用 bash "$SCRIPT_DIR/deploy.sh" 替代 $0 避免路径变化导致的权限问题
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 21:26:19 -08:00
Developer
d6227a574b
refactor(presence-service): 优化 deploy.sh 与主基础设施集成
...
- 更新容器名和镜像名与项目规范一致
- 添加 load_env 函数支持共享环境配置
- 添加 up/logs-all/clean-all 命令
- 使用动态 HEALTH_ENDPOINT
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 20:45:28 -08:00
Developer
f132b86899
feat(presence-service): 添加完整的部署脚本
...
- 添加 deploy.sh 主部署脚本 (build/start/stop/logs/migrate/test)
- 添加 scripts/quick-test.sh API 快速测试脚本
- 添加 scripts/rebuild-kafka.sh Kafka 重建脚本
- 更新 scripts/README.md 文档
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 20:16:33 -08:00
Developer
603c1c6c90
feat(presence-service): 添加完整的测试套件和生产部署设施
...
- 添加 165 个测试用例 (123 单元测试, 22 集成测试, 20 E2E测试)
- 添加 Docker 多阶段构建和 docker-compose 生产部署配置
- 添加完整的文档体系 (架构、API、开发、测试、部署)
- 添加环境配置 (.env.development/production/test)
- 添加部署脚本 (health-check, start-all, stop-service)
- 修复 TypeScript 类型错误
- 经 WSL2 验证所有生产部署命令测试通过
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 20:10:04 -08:00
Developer
0be3fe619e
feat(presence-service): 完整实现 DDD+Hexagonal 架构的用户活跃度与在线状态服务
...
Domain 层 (领域层):
- 值对象: InstallId, EventName, EventProperties, DeviceInfo, TimeWindow
- 实体: EventLog, OnlineSnapshot
- 聚合根: DailyActiveStats
- 领域事件: SessionStartedEvent, HeartbeatReceivedEvent, DauCalculatedEvent
- 仓储接口: IEventLogRepository, IDailyActiveStatsRepository, IOnlineSnapshotRepository
- 领域服务: DauCalculationService, OnlineDetectionService
Infrastructure 层 (基础设施层):
- Prisma: EventLog, DailyActiveStats, OnlineSnapshot 数据模型
- Redis: 在线状态存储 (ZSET) + HyperLogLog DAU 实时统计
- Kafka: 事件发布服务 (可选)
- Mappers: 领域对象 <-> Prisma 模型转换
- 仓储实现: EventLogRepositoryImpl, DailyActiveStatsRepositoryImpl, OnlineSnapshotRepositoryImpl
Application 层 (应用层):
- Commands: RecordEvents, RecordHeartbeat, CalculateDau
- Queries: GetOnlineCount, GetDauStats
- Schedulers: 每分钟记录在线快照, 每小时清理过期数据, 每天凌晨计算前一天DAU
API 层 (表现层):
- Controllers: AnalyticsController, PresenceController, HealthController
- DTOs: BatchEventsDto, HeartbeatDto, QueryDauDto, OnlineCountResponseDto, DauStatsResponseDto
- Guards: JwtAuthGuard
- Decorators: @Public, @CurrentUser
核心功能:
- ✅ 用户行为事件批量上报与存储
- ✅ 日活 DAU 统计 (按自然日去重, 支持省/市维度)
- ✅ 实时在线人数统计 (3分钟窗口)
- ✅ 心跳机制 (前台60秒间隔)
- ✅ HyperLogLog 实时 DAU 计数
- ✅ 定时任务 (快照记录, 过期清理, DAU 计算)
- ✅ Swagger API 文档
- ✅ Docker 多阶段构建
- ✅ 健康检查
技术栈:
- NestJS + TypeScript
- Prisma ORM + PostgreSQL
- Redis (ioredis)
- Kafka (kafkajs, 可选)
- CQRS 模式 (@nestjs/cqrs)
- 定时任务 (@nestjs/schedule)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 12:11:38 -08:00
hailin
996bc231f2
.
2025-12-03 03:51:47 +08:00
Developer
566f464a9b
wip(presence-service): 初始化项目结构
...
- 创建基础配置文件 (package.json, tsconfig.json, nest-cli.json)
- 设计 Prisma schema (heartbeats, daily_active_users, online_sessions, dau_statistics)
- 待完善: Domain/Infrastructure/Application/API层实现
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 11:47:14 -08:00