From 128682ce7730fc5b2d48361521f0336917fcfe09 Mon Sep 17 00:00:00 2001 From: prathabanKavin Date: Tue, 25 Jun 2024 09:12:24 +0530 Subject: [PATCH] Limit device percentages to two decimals --- .../mgt/core/impl/SubscriptionManagerImpl.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java index 81c3f2d680..a55ea7126f 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -1851,7 +1851,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Map statusPercentages = new HashMap<>(); for (Map.Entry entry : statusCounts.entrySet()) { double percentage = ((double) entry.getValue() / totalDevices) * 100; - statusPercentages.put(entry.getKey(), percentage); + String formattedPercentage = String.format("%.2f", percentage); + statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); } CategorizedSubscriptionResult categorizedSubscriptionResult; @@ -2033,7 +2034,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Map statusPercentages = new HashMap<>(); for (Map.Entry entry : statusCounts.entrySet()) { double percentage = ((double) entry.getValue() / totalDevices) * 100; - statusPercentages.put(entry.getKey(), percentage); + String formattedPercentage = String.format("%.2f", percentage); + statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); } CategorizedSubscriptionResult categorizedSubscriptionResult; @@ -2225,7 +2227,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Map statusPercentages = new HashMap<>(); for (Map.Entry entry : statusCounts.entrySet()) { double percentage = totalDevices == 0 ? 0.0 : ((double) entry.getValue() / totalDevices) * 100; - statusPercentages.put(entry.getKey(), percentage); + String formattedPercentage = String.format("%.2f", percentage); + statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); } CategorizedSubscriptionResult categorizedSubscriptionResult; @@ -2417,7 +2420,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Map statusPercentages = new HashMap<>(); for (Map.Entry entry : statusCounts.entrySet()) { double percentage = ((double) entry.getValue() / totalDevices) * 100; - statusPercentages.put(entry.getKey(), percentage); + String formattedPercentage = String.format("%.2f", percentage); + statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); } CategorizedSubscriptionResult categorizedSubscriptionResult; @@ -2552,7 +2556,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager { Map statusPercentages = new HashMap<>(); for (Map.Entry entry : statusCounts.entrySet()) { double percentage = ((double) entry.getValue() / totalDevices) * 100; - statusPercentages.put(entry.getKey(), percentage); + String formattedPercentage = String.format("%.2f", percentage); + statusPercentages.put(entry.getKey(), Double.valueOf(formattedPercentage)); } CategorizedSubscriptionResult categorizedSubscriptionResult =