From 0433098cea6f8d20645c6af77b458abd55f76fcc Mon Sep 17 00:00:00 2001 From: kmetin Date: Sat, 4 Nov 2023 19:58:45 +0300 Subject: [PATCH] fix Yuce's PR comments --- base/commands/migration/estimate.go | 4 ++-- base/commands/migration/estimate_stages.go | 25 +++++++++++++++++++--- internal/str/str.go | 19 ---------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/base/commands/migration/estimate.go b/base/commands/migration/estimate.go index bb40d47f4..ecd4a5a07 100644 --- a/base/commands/migration/estimate.go +++ b/base/commands/migration/estimate.go @@ -39,8 +39,8 @@ Estimation usually ends within 15 seconds.`, banner)) } resArr := res.([]string) ec.PrintlnUnnecessary("") - ec.PrintlnUnnecessary(fmt.Sprintf("OK %s", resArr[0])) - ec.PrintlnUnnecessary(fmt.Sprintf("OK %s", resArr[1])) + ec.PrintlnUnnecessary(resArr[0]) + ec.PrintlnUnnecessary(resArr[1]) ec.PrintlnUnnecessary("") ec.PrintlnUnnecessary("OK Estimation completed successfully.") return nil diff --git a/base/commands/migration/estimate_stages.go b/base/commands/migration/estimate_stages.go index 709b179f4..b1a340ec4 100644 --- a/base/commands/migration/estimate_stages.go +++ b/base/commands/migration/estimate_stages.go @@ -6,12 +6,12 @@ import ( "context" "errors" "fmt" + "strconv" "time" "github.com/hazelcast/hazelcast-commandline-client/clc/ux/stage" "github.com/hazelcast/hazelcast-commandline-client/internal/log" "github.com/hazelcast/hazelcast-commandline-client/internal/plug" - "github.com/hazelcast/hazelcast-commandline-client/internal/str" "github.com/hazelcast/hazelcast-go-client" "github.com/hazelcast/hazelcast-go-client/serialization" ) @@ -146,11 +146,11 @@ func fetchEstimationResults(ctx context.Context, ci *hazelcast.ClientInternal, m if err != nil { return nil, err } - et, err := str.MsToSecs(estimatedTime.(serialization.JSON).String()) + et, err := MsToSecs(estimatedTime.(serialization.JSON).String()) if err != nil { return nil, err } - es, err := str.BytesToMegabytes(estimatedSize.(serialization.JSON).String()) + es, err := BytesToMegabytes(estimatedSize.(serialization.JSON).String()) if err != nil { return nil, err } @@ -158,3 +158,22 @@ func fetchEstimationResults(ctx context.Context, ci *hazelcast.ClientInternal, m } return nil, errors.New("no rows found") } + +func BytesToMegabytes(bytesStr string) (string, error) { + bytes, err := strconv.ParseFloat(bytesStr, 64) + if err != nil { + return "", err + } + mb := bytes / (1024.0 * 1024.0) + return fmt.Sprintf("%.2f MBs", mb), nil +} + +func MsToSecs(ms string) (string, error) { + milliseconds, err := strconv.ParseInt(ms, 10, 64) + if err != nil { + return "", err + } + seconds := float64(milliseconds) / 1000.0 + secondsStr := fmt.Sprintf("%.1f sec", seconds) + return secondsStr, nil +} diff --git a/internal/str/str.go b/internal/str/str.go index 7daf555de..4dd34e761 100644 --- a/internal/str/str.go +++ b/internal/str/str.go @@ -59,22 +59,3 @@ func Colorize(text string) string { } return text } - -func BytesToMegabytes(bytesStr string) (string, error) { - bytes, err := strconv.ParseFloat(bytesStr, 64) - if err != nil { - return "", err - } - mb := bytes / (1024.0 * 1024.0) - return fmt.Sprintf("%.2f MBs", mb), nil -} - -func MsToSecs(ms string) (string, error) { - milliseconds, err := strconv.ParseInt(ms, 10, 64) - if err != nil { - return "", err - } - seconds := float64(milliseconds) / 1000.0 - secondsStr := fmt.Sprintf("%.1f sec", seconds) - return secondsStr, nil -}