KPI name change : GWM

This commit is contained in:
Gowtham M 2025-01-16 09:20:10 +05:30
parent 285d3f548b
commit 4ecc7d0ba2
8 changed files with 662 additions and 604 deletions

1218
main.go

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,48 @@
package utils
// ProcessChartData processes chart data with language source data to produce the result based on the language key.
func ProcessChartData(chartData []map[string]interface{}, languageSource []map[string]interface{}, langKey string) []map[string]interface{} {
// Helper function to find translation
findTranslation := func(key string, value string) string {
for _, langEntry := range languageSource {
if langEntry["key"] == key && langEntry["value"] == value {
if translatedValue, ok := langEntry[langKey]; ok {
return translatedValue.(string)
}
}
}
return value // Return the original value if no translation is found
}
// Extract unique translation keys from languageSource
translationKeys := map[string]bool{}
for _, langEntry := range languageSource {
if key, ok := langEntry["key"].(string); ok {
translationKeys[key] = true
}
}
// Process each chart data entry
result := []map[string]interface{}{}
for _, entry := range chartData {
obsKey := entry["ObsKey"].(map[string]interface{})
translatedObsKey := map[string]interface{}{}
// Translate fields in ObsKey dynamically based on extracted translation keys
for key, value := range obsKey {
if translationKeys[key] {
translatedObsKey[key] = findTranslation(key, value.(string))
} else {
translatedObsKey[key] = value
}
}
// Append the translated entry to the result
result = append(result, map[string]interface{}{
"ObsKey": translatedObsKey,
"ObsValue": entry["ObsValue"],
})
}
return result
}