删除以前版本文件
This commit is contained in:
65
CLAUDE.md
65
CLAUDE.md
@@ -55,11 +55,9 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
- 生产环境单表 + 测试环境分表
|
||||
- 生产环境单表 + 测试环境单表
|
||||
|
||||
**示例代码**
|
||||
- `demo/Query.py`: 独立的Cassandra查询比对脚本示例
|
||||
- `demo/twcsQuery.py`: 另一个查询示例
|
||||
- `demo/CalculationLibrary.py`: 分表计算逻辑参考实现
|
||||
- `test_sharding.py`: 分表功能测试脚本
|
||||
**核心文件**
|
||||
- `app.py`: 唯一的主应用文件,包含所有功能实现
|
||||
- `config_groups.db`: SQLite数据库文件
|
||||
|
||||
### 关键功能模块
|
||||
|
||||
@@ -88,38 +86,34 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
|
||||
### 环境设置
|
||||
```bash
|
||||
# 安装依赖(仅需要Flask和cassandra-driver)
|
||||
# 安装依赖
|
||||
pip install -r requirements.txt
|
||||
|
||||
# 运行应用(默认端口5000)
|
||||
python app.py
|
||||
|
||||
# 自定义端口运行
|
||||
# 修改app.py最后一行:app.run(debug=True, port=5001)
|
||||
# 修改app.py最后一行:app.run(debug=True, port=XXXX)
|
||||
```
|
||||
|
||||
### 调试和日志
|
||||
```bash
|
||||
# 应用启动后,查询日志可通过以下API获取:
|
||||
# GET /api/query-logs - 获取查询日志
|
||||
# DELETE /api/query-logs - 清空查询日志
|
||||
|
||||
# 日志级别:INFO, WARNING, ERROR
|
||||
# 所有Cassandra查询和SQL操作都会记录到查询日志中
|
||||
```
|
||||
|
||||
### 测试和验证
|
||||
```bash
|
||||
# 运行分表功能测试(测试时间戳提取和分表索引计算)
|
||||
python test_sharding.py
|
||||
# 主要通过Web界面进行功能测试
|
||||
# 单表查询测试:http://localhost:5000/db-compare
|
||||
# 分表查询测试:在Web界面中开启分表模式
|
||||
|
||||
# 测试新的分表计算规则
|
||||
python test_new_sharding.py
|
||||
|
||||
# 演示新分表规则的详细工作原理
|
||||
python demo_new_sharding.py
|
||||
|
||||
# 测试查询日志功能
|
||||
python test_query_logs.py
|
||||
|
||||
# 集成测试(分表功能 + 查询日志)
|
||||
python test_integration.py
|
||||
|
||||
# 测试数据库连接和查询功能
|
||||
# 通过Web界面:http://localhost:5000/db-compare
|
||||
# 或直接运行示例脚本:
|
||||
python demo/Query.py
|
||||
python demo/twcsQuery.py
|
||||
# 数据库初始化(如果config_groups.db不存在)
|
||||
# 通过访问Web界面会自动创建数据库表结构
|
||||
```
|
||||
|
||||
### 开发模式
|
||||
@@ -131,6 +125,12 @@ python demo/twcsQuery.py
|
||||
- Flask==2.3.3
|
||||
- cassandra-driver==3.29.1
|
||||
|
||||
### 项目特点
|
||||
- **单文件架构**:所有后端逻辑都在 `app.py` 中实现(1400+行代码)
|
||||
- **内存日志系统**:使用 `QueryLogCollector` 类在内存中收集查询日志
|
||||
- **SQLite本地存储**:配置组和查询历史存储在本地 `config_groups.db` 文件中
|
||||
- **前端原生实现**:使用原生JavaScript + Bootstrap,无现代前端框架
|
||||
|
||||
## API架构说明
|
||||
|
||||
### 核心API端点
|
||||
@@ -229,6 +229,19 @@ python demo/twcsQuery.py
|
||||
|
||||
## 开发注意事项
|
||||
|
||||
### 代码修改指导
|
||||
- **单文件开发**:所有后端功能都在 `app.py` 中,修改时要注意代码结构清晰
|
||||
- **数据库模式变更**:修改SQLite表结构需要考虑向后兼容性
|
||||
- **前端JavaScript**:位于 `static/js/app.js`,使用原生JS,注意浏览器兼容性
|
||||
- **HTML模板**:使用Jinja2模板引擎,主要文件在 `templates/` 目录
|
||||
|
||||
### 核心类和函数位置(app.py)
|
||||
- `QueryLogCollector`类:日志收集系统(第20-46行)
|
||||
- `ShardingCalculator`类:分表计算器(第64行开始)
|
||||
- 数据库连接:`create_cassandra_connection()`
|
||||
- 查询比对:`execute_query()` 和 `execute_sharding_query()`
|
||||
- API路由:使用Flask装饰器定义
|
||||
|
||||
### 分表功能开发指导
|
||||
- **时间戳解析(已更新)**:`ShardingCalculator.extract_timestamp_from_key()` 新规则
|
||||
- 使用 `re.sub(r'\D', '', key)` 删除所有非数字字符
|
||||
|
Reference in New Issue
Block a user