完善查询
This commit is contained in:
@@ -2417,7 +2417,12 @@ async function showQueryHistoryDialog() {
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div class="flex-grow-1">
|
||||
<h6 class="card-title mb-1">${history.name}</h6>
|
||||
<h6 class="card-title mb-1">
|
||||
${history.name}
|
||||
<span class="badge ${history.query_type === 'sharding' ? 'bg-primary' : 'bg-secondary'} ms-2">
|
||||
${history.query_type === 'sharding' ? '分表查询' : '单表查询'}
|
||||
</span>
|
||||
</h6>
|
||||
<p class="card-text text-muted small mb-2">${history.description || '无描述'}</p>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
@@ -2531,11 +2536,31 @@ async function loadHistoryRecord(historyId) {
|
||||
// 填充查询Key值
|
||||
document.getElementById('query_values').value = (history.query_keys || []).join('\n');
|
||||
|
||||
// 处理分表配置(如果存在)
|
||||
if (history.query_type === 'sharding' && history.sharding_config) {
|
||||
// 启用分表模式
|
||||
document.getElementById('enableSharding').checked = true;
|
||||
toggleShardingMode();
|
||||
|
||||
// 填充分表配置
|
||||
document.getElementById('use_sharding_for_pro').checked = history.sharding_config.use_sharding_for_pro || false;
|
||||
document.getElementById('use_sharding_for_test').checked = history.sharding_config.use_sharding_for_test || false;
|
||||
document.getElementById('pro_interval_seconds').value = history.sharding_config.pro_interval_seconds || 604800;
|
||||
document.getElementById('pro_table_count').value = history.sharding_config.pro_table_count || 14;
|
||||
document.getElementById('test_interval_seconds').value = history.sharding_config.test_interval_seconds || 604800;
|
||||
document.getElementById('test_table_count').value = history.sharding_config.test_table_count || 14;
|
||||
} else {
|
||||
// 禁用分表模式
|
||||
document.getElementById('enableSharding').checked = false;
|
||||
toggleShardingMode();
|
||||
}
|
||||
|
||||
// 关闭历史记录modal
|
||||
const modal = bootstrap.Modal.getInstance(document.getElementById('queryHistoryModal'));
|
||||
modal.hide();
|
||||
|
||||
showAlert('success', `历史记录 "${history.name}" 加载成功`);
|
||||
const queryTypeDesc = history.query_type === 'sharding' ? '分表查询' : '单表查询';
|
||||
showAlert('success', `${queryTypeDesc}历史记录 "${history.name}" 加载成功`);
|
||||
} else {
|
||||
showAlert('danger', result.error || '加载历史记录失败');
|
||||
}
|
||||
@@ -2803,6 +2828,15 @@ async function saveHistoryRecord() {
|
||||
|
||||
const config = getCurrentConfig();
|
||||
|
||||
// 确定查询类型和获取相应配置
|
||||
let queryType = 'single';
|
||||
let shardingConfig = null;
|
||||
|
||||
if (isShardingMode) {
|
||||
queryType = 'sharding';
|
||||
shardingConfig = getShardingConfig().sharding_config;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/query-history', {
|
||||
method: 'POST',
|
||||
@@ -2820,7 +2854,10 @@ async function saveHistoryRecord() {
|
||||
execution_time: 0.0,
|
||||
total_keys: currentResults.total_keys,
|
||||
differences_count: currentResults.differences.length,
|
||||
identical_count: currentResults.identical_results.length
|
||||
identical_count: currentResults.identical_results.length,
|
||||
// 新增分表相关字段
|
||||
sharding_config: shardingConfig,
|
||||
query_type: queryType
|
||||
})
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user