diff --git a/yb-voyager/cmd/migration_complexity.go b/yb-voyager/cmd/migration_complexity.go index 0c974d449..d9868a082 100644 --- a/yb-voyager/cmd/migration_complexity.go +++ b/yb-voyager/cmd/migration_complexity.go @@ -240,7 +240,7 @@ const explainTemplateHTML = `
Level-1 Impact: Resolutions are available with minimal effort.
Level-2 Impact: Resolutions are available requiring moderate effort.
- Level-3 Impact: Resolutions may not be available or are highly complex.
+ Level-3 Impact: Resolutions may not be available or are complex.
@@ -250,12 +250,12 @@ const explainTemplateHTML = ` const explainTemplateText = `Reasoning: {{ .ComplexityRationale }}` -type ExplanationData struct { - Summaries []CategorySummary +type MigrationComplexityExplanationData struct { + Summaries []MigrationComplexityCategorySummary ComplexityRationale string // short reasoning or explanation text } -type CategorySummary struct { +type MigrationComplexityCategorySummary struct { Category string TotalIssueCount int ImpactCounts map[string]int // e.g. {"Level-1": 3, "Level-2": 5, "Level-3": 2} @@ -266,7 +266,7 @@ func buildMigrationComplexityExplanation(sourceDBType string, assessmentReport A return "", nil } - var explanation ExplanationData + var explanation MigrationComplexityExplanationData explanation.ComplexityRationale = migrationComplexityRationale explanation.Summaries = buildCategorySummary(assessmentReport.Issues) @@ -302,15 +302,15 @@ func buildRationale(finalComplexity string, l1Count int, l2Count int, l3Count in return "" } -func buildCategorySummary(issues []AssessmentIssue) []CategorySummary { - summaryMap := make(map[string]*CategorySummary) +func buildCategorySummary(issues []AssessmentIssue) []MigrationComplexityCategorySummary { + summaryMap := make(map[string]*MigrationComplexityCategorySummary) for _, issue := range issues { if issue.Category == "" { continue // skipping unknown category issues } if _, ok := summaryMap[issue.Category]; !ok { - summaryMap[issue.Category] = &CategorySummary{ + summaryMap[issue.Category] = &MigrationComplexityCategorySummary{ Category: issue.Category, TotalIssueCount: 0, ImpactCounts: make(map[string]int), @@ -321,9 +321,9 @@ func buildCategorySummary(issues []AssessmentIssue) []CategorySummary { summaryMap[issue.Category].ImpactCounts[issue.Impact]++ } - var result []CategorySummary + var result []MigrationComplexityCategorySummary for _, summary := range summaryMap { - summary.Category = utils.ToTitleCase(summary.Category) + summary.Category = utils.SnakeCaseToTitleCase(summary.Category) result = append(result, *summary) } return result diff --git a/yb-voyager/src/utils/utils.go b/yb-voyager/src/utils/utils.go index ed002ec78..c9967e455 100644 --- a/yb-voyager/src/utils/utils.go +++ b/yb-voyager/src/utils/utils.go @@ -38,6 +38,8 @@ import ( "github.com/samber/lo" log "github.com/sirupsen/logrus" "golang.org/x/exp/slices" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) var DoNotPrompt bool @@ -745,12 +747,13 @@ func BuildObjectName(schemaName, objName string) string { return lo.Ternary(schemaName != "", schemaName+"."+objName, objName) } -// ToTitleCase converts a snake_case string to a title case string with spaces. -func ToTitleCase(snake string) string { +// SnakeCaseToTitleCase converts a snake_case string to a title case string with spaces. +func SnakeCaseToTitleCase(snake string) string { words := strings.Split(snake, "_") + c := cases.Title(language.English) for i, word := range words { - words[i] = strings.Title(word) + words[i] = c.String(word) } - + return strings.Join(words, " ") -} \ No newline at end of file +}