package feishu

// SlowQueryTableFieldConfigs Default table field configurations
var SlowQueryTableFieldConfigs = []TableFieldConfig{
	{FieldName: "Digest（Click to list）", Type: 0, IsHeader: true}, // Header only
	{FieldName: "ClusterAlias", Type: 1},
	{FieldName: "IsNewDigest", Type: 1},
	{FieldName: "Query（Click to detail）", Type: 15},
	{FieldName: "Latency (Avg|Max)", Type: 1},
	{FieldName: "RU (Avg|SUM)", Type: 1},
	{FieldName: "Memory (Avg|Max)", Type: 1},
	{FieldName: "Count", Type: 2, Property: map[string]interface{}{"formatter": "0"}},
	{FieldName: "MaxCPUTimeIn5MinWindow(m)", Type: 1},
	{FieldName: "Max5MinWindowTime(UTC)", Type: 1},
	{FieldName: "MaxInstance（TopSql link)", Type: 15},
	{FieldName: "TotalCPUTimeInDay(m)", Type: 1},
	{FieldName: "PatternSuggestion", Type: 1},
}

// slowQueryTableFieldConfigs Default table field configurations
var TopSqlSeedTable = []TableFieldConfig{
	{FieldName: "Digest（Click to list）", Type: 0, IsHeader: true}, // Header only
	{FieldName: "ClusterAlias", Type: 1},
	{FieldName: "Query（Click to detail）", Type: 15},
	{FieldName: "Count", Type: 2, Property: map[string]interface{}{"formatter": "0.00"}},
	{FieldName: "CountDiff", Type: 1},
	{FieldName: "CpuTimeInDay(m)", Type: 1},
	{FieldName: "CpuDiff", Type: 1},
	{FieldName: "IsNew", Type: 1},
	{FieldName: "Reason", Type: 1},
}

var TopSqlSkipTable = []TableFieldConfig{
	{FieldName: "Digest（Click to list）", Type: 0, IsHeader: true}, // Header only
	{FieldName: "ClusterAlias", Type: 1},
	{FieldName: "Query（Click to detail）", Type: 15},
	{FieldName: "Count", Type: 2, Property: map[string]interface{}{"formatter": "0.00"}},
	{FieldName: "CountDiff", Type: 1},
	{FieldName: "CpuTimeInDay(m)", Type: 1},
	{FieldName: "CpuDiff", Type: 1},
	{FieldName: "Reason", Type: 1},
}

type CardTemplateContent struct {
	Type string       `json:"type"`
	Data TemplateData `json:"data"`
}

// Feishu message card - table data variables
type TableRow struct {
	PatternName string `json:"pattern_name"`
	Total       string `json:"total"`
	NewDigest   string `json:"new_digest"`
}

// Feishu message card template variables
type TemplateVariable struct {
	OrgName       string     `json:"org_name"`
	Day           string     `json:"day"`
	RiskText      string     `json:"risk_text"`
	TitleColor    string     `json:"title_color"`
	DocLink       Link       `json:"doc_link"`
	TableRawArray []TableRow `json:"table_raw_array"`
}

type TemplateData struct {
	TemplateID          string           `json:"template_id"`
	TemplateVersionName string           `json:"template_version_name"`
	TemplateVariable    TemplateVariable `json:"template_variable"`
}

type Link struct {
	PcUrl      string `json:"pc_url"`
	AndroidUrl string `json:"android_url"`
	IosUrl     string `json:"ios_url"`
	Url        string `json:"url"`
}
