handle negative values, fix 1
This commit is contained in:
@ -56,6 +56,9 @@ func calculateDifference(key string, newValue string) (string, error) {
|
||||
Timestamp: currentTime,
|
||||
Value: newValue,
|
||||
}
|
||||
if diffValuePerSecond < 0 {
|
||||
return "", fmt.Errorf("negative difference value: %d", diffValuePerSecond)
|
||||
}
|
||||
return strconv.Itoa(diffValuePerSecond), nil
|
||||
} else {
|
||||
log.Printf("create lvv for %s", key)
|
||||
@ -122,8 +125,6 @@ func Start() {
|
||||
if err != nil {
|
||||
log.Printf("Error when building difference: %v", err)
|
||||
convertedValue = "-1"
|
||||
} else if diff < 0 {
|
||||
convertedValue = "-2"
|
||||
} else {
|
||||
convertedValue = diff
|
||||
}
|
||||
|
Reference in New Issue
Block a user