You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Tasks: Analysis Storage Refactor

1. StorageManager 扩展

  • 1.1 在 StorageManager 中新增 get_analysis_data() 方法,支持 analysis 表读取
  • 1.2 在 StorageManager 中新增 save_analysis_data() 方法,支持 analysis 表写入
  • 1.3 在 StorageManager 中新增 save_analysis_with_timestamp() 方法,支持原子写入

2. 数据迁移

  • 2.1 创建 app/analysis_migration.py,实现 SQLite → MySQL 迁移逻辑
  • 2.2 在 app/main.pylifespan 中调用迁移函数,启动时自动迁移
  • 2.3 迁移幂等性:检测 MySQL 表是否已有数据,有则跳过

3. 降级逻辑集成

  • 3.1 修改 app/analysis_db.py,使用 StorageManager 进行读写
  • 3.2 实现 MySQL 不可用时降级到 SQLite 的逻辑
  • 3.3 实现 Redis 缓存命中/未命中的逻辑

4. 表结构初始化

  • 4.1 在 app/main.pylifespan 中创建 analysis 表MySQL
  • 4.2 验证 14 张表在 MySQL 中正确创建

5. 测试与验证

  • 5.1 验证 Redis 缓存命中场景
  • 5.2 验证 Redis 缓存未命中回源 MySQL 场景
  • 5.3 验证 MySQL 不可用降级到 SQLite 场景
  • 5.4 验证数据迁移完整性
  • 5.5 验证现有功能AI 分析、复盘计划、交易记录)正常工作