Skip to content

Commit

Permalink
Fixed NaN values in Cost Analysis aggregate APIs (#13708)
Browse files Browse the repository at this point in the history
* fixed nan in aggregations

* review comments
  • Loading branch information
OnkarVO7 authored Oct 25, 2023
1 parent 452a33b commit b89f5ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ public List<Object> aggregate() throws ParseException {
Double used = Objects.requireNonNullElse(getValue(totalUsed), 0.0);
Double unused = Objects.requireNonNullElse(getValue(totalUnused), 0.0);
Double total = used + unused;
Double usedPercentage = used / total;
Double unusedPercentage = unused / total;

Double usedPercentage = 0.0;
Double unusedPercentage = 0.0;
if (total != 0.0) {
usedPercentage = used / total;
unusedPercentage = unused / total;
}
data.add(
new AggregatedUsedVsUnusedAssetsCount()
.withTimestamp(timestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ public List<Object> aggregate() throws ParseException {
Double used = Objects.requireNonNullElse(getValue(totalUsed), 0.0);
Double unused = Objects.requireNonNullElse(getValue(totalUnused), 0.0);
Double total = used + unused;
Double usedPercentage = used / total;
Double unusedPercentage = unused / total;

Double usedPercentage = 0.0;
Double unusedPercentage = 0.0;
if (total != 0.0) {
usedPercentage = used / total;
unusedPercentage = unused / total;
}
data.add(
new AggregatedUsedVsUnusedAssetsSize()
.withTimestamp(timestamp)
Expand Down

0 comments on commit b89f5ea

Please sign in to comment.