fix(exports): 优化导出接口的行数估算逻辑
- 修改估算行数的回退逻辑,使用精确 COUNT 替代原先的快速估算 - 添加日志记录精确统计阶段的相关信息,便于跟踪统计过程 - 修正导出接口的估算准确性,提升导出性能和稳定性 fix(metadata): 隐藏 marketingMetadataTables 中键“绑定类型”字段 - 将绑定类型字段的 Hidden 属性由 false 改为 true - 避免绑定类型字段在某些场景下被展示 - 保持批次相关字段显示的合理性和安全性
This commit is contained in:
parent
83339f42a3
commit
553704c836
|
|
@ -305,7 +305,7 @@ func (a *ExportsAPI) create(w http.ResponseWriter, r *http.Request) {
|
|||
fail(w, r, http.StatusBadRequest, fmt.Sprintf("EXPLAIN 未通过:评分=%d,请优化索引或缩小查询范围", score))
|
||||
return
|
||||
}
|
||||
// 估算行数(优先使用分块统计,失败或结果为 0 时回退到单次 COUNT)
|
||||
// 估算行数(优先使用分块统计,失败或结果为 0 时回退到精确 COUNT)
|
||||
var estimate int64
|
||||
estimate = rrepo.EstimateFastChunked(dataDB, ds, main, p.Filters)
|
||||
if estimate <= 0 {
|
||||
|
|
@ -314,8 +314,20 @@ func (a *ExportsAPI) create(w http.ResponseWriter, r *http.Request) {
|
|||
"datasource": ds,
|
||||
"main_table": main,
|
||||
"filters": p.Filters,
|
||||
"stage": "fast_chunked",
|
||||
"estimate": estimate,
|
||||
})
|
||||
// 使用完整导出 SQL 做一次精确统计,避免分表/索引等原因导致估算为 0
|
||||
estimate = exporter.CountRows(dataDB, q, args)
|
||||
logging.JSON("INFO", map[string]interface{}{
|
||||
"event": "estimate_exact_count",
|
||||
"datasource": ds,
|
||||
"main_table": main,
|
||||
"filters": p.Filters,
|
||||
"sql": q,
|
||||
"args": args,
|
||||
"estimate": estimate,
|
||||
})
|
||||
estimate = rrepo.EstimateFast(dataDB, ds, main, p.Filters)
|
||||
}
|
||||
hdrs := make([]string, len(filtered))
|
||||
for i, tf := range filtered {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ func marketingMetadataTables() []tableInfo {
|
|||
{Key: "key_batch.plan_id", Field: "plan_id", Label: "计划编号", Hidden: true},
|
||||
{Key: "key_batch.style", Field: "style", Label: "KEY样式", Hidden: false},
|
||||
{Key: "key_batch.batch_name", Field: "batch_name", Label: "KEY批次名称", Hidden: false},
|
||||
{Key: "key_batch.bind_object", Field: "bind_object", Label: "绑定类型", Hidden: false},
|
||||
{Key: "key_batch.bind_object", Field: "bind_object", Label: "绑定类型", Hidden: true},
|
||||
{Key: "key_batch.quantity", Field: "quantity", Label: "发放KEY数量", Hidden: true},
|
||||
{Key: "key_batch.stock", Field: "stock", Label: "剩余库存信息", Hidden: true},
|
||||
{Key: "key_batch.allow_repetition", Field: "allow_repetition", Label: "允许商品重复选择:1允许,0不允许", Hidden: true},
|
||||
|
|
|
|||
Loading…
Reference in New Issue