|
@@ -1453,10 +1453,6 @@ func (this *EdbInfoController) QueryEdbDataTable() {
|
|
|
br.ErrMsg = "获取指标信息失败,err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- // todo 兼容mongo
|
|
|
- tableName := data_manage.GetEdbDataTableName(edbInfo.Source, edbInfo.SubSource)
|
|
|
-
|
|
|
columnList := []map[string]string{
|
|
|
{
|
|
|
"edb_code": "指标code",
|
|
@@ -1469,7 +1465,15 @@ func (this *EdbInfoController) QueryEdbDataTable() {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- templateStr := fmt.Sprintf("sql1 = f\"\"\"SELECT data_time,`value` FROM %s WHERE edb_code = '%s' ORDER BY data_time DESC;\"\"\"\nraw = pandas_fetch_all(sql1, db)", tableName, edbInfo.EdbCode)
|
|
|
+ // todo 兼容mongo
|
|
|
+ tableName := data_manage.GetEdbDataTableName(edbInfo.Source, edbInfo.SubSource)
|
|
|
+
|
|
|
+ var templateStr string
|
|
|
+ if edbInfo.Source == utils.DATA_SOURCE_BUSINESS {
|
|
|
+ templateStr = fmt.Sprintf("# 查询条件\nquery = {\"edb_code\": \"%s\"}\n# 排序\nsort = [(\"data_time\", -1)] # -1 表示降序排列,对应 SQL 的 DESC\nprojection = {\"data_time\": 1, \"value\": 1, \"_id\": 0} # 只选择data_time和value字段,忽略_id字段\n# 使用 find() 方法获取数据,然后使用 aggregate() 转换为列表\nraw_data = list(collection.find(query, projection).sort(sort))\n# 将结果转换为 DataFrame\nraw = pd.DataFrame(raw_data)\n# 转换data_time字段为东八区时间\nraw['data_time'] = raw['data_time'].apply(lambda x: x.replace(tzinfo=utc_tz)).dt.tz_convert(local_tz).dt.strftime('%s')", edbInfo.EdbCode, "%Y-%m-%d")
|
|
|
+ } else {
|
|
|
+ templateStr = fmt.Sprintf("sql1 = f\"\"\"SELECT data_time,`value` FROM %s WHERE edb_code = '%s' ORDER BY data_time DESC;\"\"\"\nraw = pandas_fetch_all(sql1, db)", tableName, edbInfo.EdbCode)
|
|
|
+ }
|
|
|
info := data_manage.TableInfoResp{
|
|
|
ColumnList: columnList,
|
|
|
TableName: tableName,
|