From 08a88600efafe409664470e5c065c5e096377458 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Wed, 26 May 2021 02:05:45 +0200 Subject: [PATCH] Fixed registration type stats. --- src/fr/devinsy/statoolinfos/core/Service.java | 22 ++++++++++ .../devinsy/statoolinfos/stats/StatAgent.java | 41 +++++++++++++++++-- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java index ec47fff..f96206f 100644 --- a/src/fr/devinsy/statoolinfos/core/Service.java +++ b/src/fr/devinsy/statoolinfos/core/Service.java @@ -878,6 +878,28 @@ public class Service extends PathPropertyList return result; } + /** + * Checks if is registration unknown. + * + * @return true, if is registration unknown + */ + public boolean isRegistrationUnknown() + { + boolean result; + + if (isRegistrationNone() || isRegistrationFree() || isRegistrationMember() || isRegistrationClient()) + { + result = false; + } + else + { + result = true; + } + + // + return result; + } + public void setInputFile(final File inputFile) { this.inputFile = inputFile; diff --git a/src/fr/devinsy/statoolinfos/stats/StatAgent.java b/src/fr/devinsy/statoolinfos/stats/StatAgent.java index f3dbbfb..9b7e1c0 100644 --- a/src/fr/devinsy/statoolinfos/stats/StatAgent.java +++ b/src/fr/devinsy/statoolinfos/stats/StatAgent.java @@ -320,19 +320,23 @@ public class StatAgent { result.inc(RegistrationType.NONE); } - else if (service.isRegistrationFree()) + + if (service.isRegistrationFree()) { result.inc(RegistrationType.FREE); } - else if (service.isRegistrationMember()) + + if (service.isRegistrationMember()) { result.inc(RegistrationType.MEMBER); } - else if (service.isRegistrationClient()) + + if (service.isRegistrationClient()) { result.inc(RegistrationType.CLIENT); } - else + + if (service.isRegistrationUnknown()) { result.inc(RegistrationType.UNKNOWN); } @@ -489,4 +493,33 @@ public class StatAgent // return result; } + + /** + * Stats organization turnout. + * + * @param service + * the service + * @return the organization turnout stats + */ + public static OrganizationTurnoutStats statsOrganizationTurnout(final Service service) + { + OrganizationTurnoutStats result; + + result = new OrganizationTurnoutStats(); + + // + PathPropertyList lines = service.getByPattern("metrics\\..*\\.\\d{4}\\.(months|weeks|days)"); + + if (lines.hasFilledValue()) + { + result.incWithServiceMetricCount(); + } + else + { + result.incWithServiceFileCount(); + } + + // + return result; + } }