This commit is contained in:
zhangkun9038@dingtalk.com 2025-03-29 21:27:42 +08:00
parent 9bddb6d020
commit 041c3211bc
2 changed files with 4918 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package elasticilm package elasticilm
import ( import (
"encoding/json"
"fmt" "fmt"
// "math" // "math"
"testing" "testing"
@ -46,11 +47,23 @@ func TestEnsureILMPolicy(t *testing.T) {
results = append(results, row) results = append(results, row)
} }
// 打印结果矩阵 // 将结果存储为结构化数据
resultMap := make(map[string][]map[string]string)
for i, period := range timeFrames { for i, period := range timeFrames {
fmt.Printf("Time Frame: %s\n", period) periodResults := make([]map[string]string, 0)
for j, result := range results[i] { for j, result := range results[i] {
fmt.Printf(" Month: %s - %s\n", startDate.AddDate(0, j, 0).Format("2006-01"), result) month := startDate.AddDate(0, j, 0).Format("2006-01")
periodResults = append(periodResults, map[string]string{"Month": month, "Result": result})
} }
resultMap[period] = periodResults
} }
// 将结果编码为JSON格式
jsonData, err := json.MarshalIndent(resultMap, "", " ")
if err != nil {
t.Fatalf("Failed to encode results to JSON: %v", err)
}
// 打印JSON结果
fmt.Println(string(jsonData))
} }

4902
elasticilm/warmDay.json Normal file

File diff suppressed because it is too large Load Diff