Skip to content

Commit

Permalink
Feat : resolved review comments (#62)
Browse files Browse the repository at this point in the history
 resolved : review comments
---------

Co-authored-by: Jyothi Surampudi <[email protected]>
Co-authored-by: jsurampudi <[email protected]>
Co-authored-by: Rahul Reddy <[email protected]>
  • Loading branch information
4 people authored Jan 28, 2025
1 parent 4ed8799 commit 2bf940a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
20 changes: 6 additions & 14 deletions src/query-performance-monitoring/common-utils/common_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,15 @@ import (
// re is a regular expression that matches single-quoted strings, numbers, or double-quoted strings
var re = regexp.MustCompile(`'[^']*'|\d+|".*?"`)

func GetQuotedStringFromArray(array []string) string {
var quotedNames = make([]string, 0)
for _, name := range array {
quotedNames = append(quotedNames, fmt.Sprintf("'%s'", name))
}
return strings.Join(quotedNames, ",")
}

func GetDatabaseListInString(dbMap collection.DatabaseList) string {
var databaseNames = make([]string, 0)
for dbName := range dbMap {
databaseNames = append(databaseNames, dbName)
}
if len(databaseNames) == 0 {
if len(dbMap) == 0 {
return ""
}
return GetQuotedStringFromArray(databaseNames)
var quotedNames = make([]string, 0)
for dbName := range dbMap {
quotedNames = append(quotedNames, fmt.Sprintf("'%s'", dbName))
}
return strings.Join(quotedNames, ",")
}

func AnonymizeQueryText(query string) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ import (
"github.com/stretchr/testify/assert"
)

func TestGetQuotedStringFromArray(t *testing.T) {
input := []string{"db1", "db2", "db3"}
expected := "'db1','db2','db3'"
result := commonutils.GetQuotedStringFromArray(input)
assert.Equal(t, expected, result)
}

func TestGetDatabaseListInString(t *testing.T) {
dbListKeys := []string{"db1"}
sort.Strings(dbListKeys) // Sort the keys to ensure consistent order
Expand Down

0 comments on commit 2bf940a

Please sign in to comment.