From 920be72700b96c70dc2d6dcb062949d69fb47510 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Fri, 20 Nov 2020 13:22:48 +0100 Subject: [PATCH] Improved organization turnout stats. --- src/fr/devinsy/statoolinfos/core/Service.java | 36 +++++++++++++++++++ .../statoolinfos/htmlize/Htmlizer.java | 6 ++-- .../devinsy/statoolinfos/stats/StatAgent.java | 2 +- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java index 3c11da5..93683a3 100644 --- a/src/fr/devinsy/statoolinfos/core/Service.java +++ b/src/fr/devinsy/statoolinfos/core/Service.java @@ -22,6 +22,7 @@ import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.time.LocalDateTime; +import java.util.Iterator; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -671,6 +672,41 @@ public class Service extends PathPropertyList return result; } + /** + * Checks for filled metrics. + * + * @return true, if successful + */ + public boolean hasFilledMetrics() + { + boolean result; + + boolean ended = false; + Iterator iterator = this.iterator(); + result = false; + while (!ended) + { + if (iterator.hasNext()) + { + PathProperty property = iterator.next(); + + if (StringUtils.isNotBlank(property.getValue())) + { + ended = true; + result = true; + } + } + else + { + ended = true; + result = false; + } + } + + // + return result; + } + /** * Checks if is registration client. * diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java index 2e2dcc0..c0d683e 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java @@ -354,9 +354,9 @@ public class Htmlizer OrganizationTurnoutStats stats = StatAgent.statsOrganizationTurnout(organizations); PieChart pie = new PieChart("Participation"); - pie.add("Active 1", stats.getWithSelfFileCount(), ChartColor.GREEN); - pie.add("Active 2", stats.getWithServiceFileCount(), ChartColor.YELLOW); - pie.add("Active 3", stats.getWithServiceMetricCount(), ChartColor.ORANGE); + pie.add("Active A", stats.getWithSelfFileCount(), ChartColor.ORANGE); + pie.add("Active B", stats.getWithServiceFileCount(), ChartColor.YELLOW); + pie.add("Active C", stats.getWithServiceMetricCount(), ChartColor.GREEN); pie.add("Passive", stats.getPassiveCount(), ChartColor.BLUE); pie.setLegendPosition(Position.RIGHT); diff --git a/src/fr/devinsy/statoolinfos/stats/StatAgent.java b/src/fr/devinsy/statoolinfos/stats/StatAgent.java index 7bb3a37..bfb91e1 100644 --- a/src/fr/devinsy/statoolinfos/stats/StatAgent.java +++ b/src/fr/devinsy/statoolinfos/stats/StatAgent.java @@ -381,7 +381,7 @@ public class StatAgent { Service service = iterator.next(); - if (!service.getByPrefix("metrics.").isEmpty()) + if (service.hasFilledMetrics()) { ended = true; result.incWithServiceMetricCount();