删除以前版本文件
This commit is contained in:
53
app.py
53
app.py
@@ -1,4 +1,4 @@
|
||||
from flask import Flask, render_template, request, jsonify
|
||||
from flask import Flask, render_template, request, jsonify, send_from_directory
|
||||
from cassandra.cluster import Cluster
|
||||
from cassandra.auth import PlainTextAuthProvider
|
||||
import json
|
||||
@@ -455,7 +455,7 @@ DEFAULT_CONFIG = {
|
||||
'keyspace': '',
|
||||
'table': ''
|
||||
},
|
||||
'keys': ['docid'],
|
||||
'keys': [],
|
||||
'fields_to_compare': [],
|
||||
'exclude_fields': []
|
||||
}
|
||||
@@ -536,7 +536,9 @@ def get_config_group_by_id(group_id):
|
||||
|
||||
try:
|
||||
cursor.execute('''
|
||||
SELECT * FROM config_groups WHERE id = ?
|
||||
SELECT id, name, description, pro_config, test_config, query_config,
|
||||
sharding_config, created_at, updated_at
|
||||
FROM config_groups WHERE id = ?
|
||||
''', (group_id,))
|
||||
row = cursor.fetchone()
|
||||
|
||||
@@ -552,25 +554,12 @@ def get_config_group_by_id(group_id):
|
||||
'updated_at': row['updated_at']
|
||||
}
|
||||
|
||||
# 添加分表配置(如果存在)
|
||||
sharding_config_data = None
|
||||
try:
|
||||
# 尝试获取sharding_config字段
|
||||
sharding_config_data = row[len(row) - 3] # sharding_config在倒数第三个位置
|
||||
except (IndexError, KeyError):
|
||||
# 如果字段不存在,尝试通过列名获取
|
||||
# 添加分表配置
|
||||
if row['sharding_config']:
|
||||
try:
|
||||
cursor.execute("PRAGMA table_info(config_groups)")
|
||||
columns = cursor.fetchall()
|
||||
column_names = [col[1] for col in columns]
|
||||
if 'sharding_config' in column_names:
|
||||
sharding_index = column_names.index('sharding_config')
|
||||
sharding_config_data = row[sharding_index]
|
||||
except:
|
||||
pass
|
||||
|
||||
if sharding_config_data:
|
||||
config['sharding_config'] = json.loads(sharding_config_data)
|
||||
config['sharding_config'] = json.loads(row['sharding_config'])
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
config['sharding_config'] = None
|
||||
else:
|
||||
config['sharding_config'] = None
|
||||
|
||||
@@ -1071,6 +1060,11 @@ def generate_recommendations(consistency_percentage, missing_in_test, missing_in
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
@app.route('/test-config-load')
|
||||
def test_config_load():
|
||||
"""配置加载测试页面"""
|
||||
return send_from_directory('.', 'test_config_load.html')
|
||||
|
||||
@app.route('/db-compare')
|
||||
def db_compare():
|
||||
return render_template('db_compare.html')
|
||||
@@ -1305,11 +1299,18 @@ def api_save_config_group():
|
||||
description = data.get('description', '').strip()
|
||||
pro_config = data.get('pro_config', {})
|
||||
test_config = data.get('test_config', {})
|
||||
query_config = {
|
||||
'keys': data.get('keys', []),
|
||||
'fields_to_compare': data.get('fields_to_compare', []),
|
||||
'exclude_fields': data.get('exclude_fields', [])
|
||||
}
|
||||
|
||||
# 获取查询配置,支持两种格式
|
||||
if 'query_config' in data:
|
||||
# 嵌套格式
|
||||
query_config = data.get('query_config', {})
|
||||
else:
|
||||
# 平铺格式
|
||||
query_config = {
|
||||
'keys': data.get('keys', []),
|
||||
'fields_to_compare': data.get('fields_to_compare', []),
|
||||
'exclude_fields': data.get('exclude_fields', [])
|
||||
}
|
||||
|
||||
# 提取分表配置
|
||||
sharding_config = data.get('sharding_config')
|
||||
|
Reference in New Issue
Block a user