From 94f807dfade0c2d2711f9ec48235fdb916d4bd76 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Fri, 4 Mar 2022 18:23:01 +0100 Subject: [PATCH] Added emoji, userCount, visitCount and column sorting. --- .../statoolinfos/htmlize/CategoriesPage.java | 8 ++-- .../statoolinfos/htmlize/SoftwaresPage.java | 8 ++-- .../statoolinfos/htmlize/categories.xhtml | 48 ++++++++++++++++--- .../statoolinfos/htmlize/softwares.xhtml | 48 ++++++++++++++++--- .../devinsy/statoolinfos/stats/StatAgent.java | 9 +++- .../stats/categories/CategoryStat.java | 35 +++++++++++++- .../stats/softwares/SoftwareStat.java | 36 +++++++++++++- 7 files changed, 168 insertions(+), 24 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/htmlize/CategoriesPage.java b/src/fr/devinsy/statoolinfos/htmlize/CategoriesPage.java index c032e6a..90d69c2 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/CategoriesPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/CategoriesPage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Christian Pierre MOMON + * Copyright (C) 2020-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -30,6 +30,7 @@ import fr.devinsy.statoolinfos.HtmlizerContext; import fr.devinsy.statoolinfos.core.Categories; import fr.devinsy.statoolinfos.core.Federation; import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.statoolinfos.core.StatoolInfosUtils; import fr.devinsy.statoolinfos.stats.StatAgent; import fr.devinsy.statoolinfos.stats.categories.CategoryStat; import fr.devinsy.statoolinfos.stats.categories.CategoryStats; @@ -93,8 +94,9 @@ public class CategoriesPage data.setEscapedContent("categoryListLine", index, "categoryListLineSoftwares", stat.getCategory().getSoftwares().sort().toStringWithFrenchCommas()); data.setContent("categoryListLine", index, "categoryListLineOrganizationCount", stat.getOrganizationCount()); - data.setContent("categoryListLine", index, "categoryListLineServiceCount", stat.getServiceCount()); - data.setContent("categoryListLine", index, "categoryListLineUserCount", stat.getUserCount()); + data.setContent("categoryListLine", index, "categoryListLineServiceCount", StatoolInfosUtils.defaultIfZero(stat.getServiceCount(), "😿")); + data.setContent("categoryListLine", index, "categoryListLineUserCount", StatoolInfosUtils.defaultIfZero(stat.getUserCount(), "😢")); + data.setContent("categoryListLine", index, "categoryListLineVisitCount", StatoolInfosUtils.defaultIfZero(stat.getVisitCount(), "😞")); index += 1; } diff --git a/src/fr/devinsy/statoolinfos/htmlize/SoftwaresPage.java b/src/fr/devinsy/statoolinfos/htmlize/SoftwaresPage.java index d79e446..ec39fad 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/SoftwaresPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/SoftwaresPage.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Christian Pierre MOMON + * Copyright (C) 2020-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -30,6 +30,7 @@ import fr.devinsy.statoolinfos.HtmlizerContext; import fr.devinsy.statoolinfos.core.Categories; import fr.devinsy.statoolinfos.core.Federation; import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.statoolinfos.core.StatoolInfosUtils; import fr.devinsy.statoolinfos.htmlize.CategoriesView.Mode; import fr.devinsy.statoolinfos.stats.StatAgent; import fr.devinsy.statoolinfos.stats.softwares.SoftwareStat; @@ -93,8 +94,9 @@ public class SoftwaresPage data.setContent("softwareListLine", index, "softwareListLineCategory", CategoriesView.build(stat.getCategories(), Mode.ALL)); data.setContent("softwareListLine", index, "softwareListLineOrganizationCount", stat.getOrganizationCount()); - data.setContent("softwareListLine", index, "softwareListLineServiceCount", stat.getServiceCount()); - data.setContent("softwareListLine", index, "categoryListLineUserCount", stat.getUserCount()); + data.setContent("softwareListLine", index, "softwareListLineServiceCount", StatoolInfosUtils.defaultIfZero(stat.getServiceCount(), "😿")); + data.setContent("softwareListLine", index, "softwareListLineUserCount", StatoolInfosUtils.defaultIfZero(stat.getUserCount(), "😢")); + data.setContent("softwareListLine", index, "softwareListLineVisitCount", StatoolInfosUtils.defaultIfZero(stat.getVisitCount(), "😞")); index += 1; } diff --git a/src/fr/devinsy/statoolinfos/htmlize/categories.xhtml b/src/fr/devinsy/statoolinfos/htmlize/categories.xhtml index 3f6ac17..6006726 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/categories.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/categories.xhtml @@ -15,7 +15,7 @@

Catégories

-
Nombre de catégories : n/a
+
n/a catégories
@@ -25,6 +25,7 @@ + @@ -39,17 +40,52 @@ +
Services Organisations Utilisateurs mensuelsVisites mensuelles
n/a n/a n/an/a
diff --git a/src/fr/devinsy/statoolinfos/htmlize/softwares.xhtml b/src/fr/devinsy/statoolinfos/htmlize/softwares.xhtml index 21563da..59badf2 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/softwares.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/softwares.xhtml @@ -15,7 +15,7 @@

Logiciels

-
Nombre de logiciels : n/a
+
n/a logiciels
@@ -25,6 +25,7 @@ + @@ -36,17 +37,52 @@ +
Services Organisations Utilisateurs mensuelsVisites mensuelles
n/a n/a n/an/a
diff --git a/src/fr/devinsy/statoolinfos/stats/StatAgent.java b/src/fr/devinsy/statoolinfos/stats/StatAgent.java index f2d7f28..0f3cb94 100644 --- a/src/fr/devinsy/statoolinfos/stats/StatAgent.java +++ b/src/fr/devinsy/statoolinfos/stats/StatAgent.java @@ -20,6 +20,7 @@ package fr.devinsy.statoolinfos.stats; import java.io.IOException; import java.net.MalformedURLException; +import java.time.YearMonth; import java.util.Iterator; import org.apache.commons.lang3.StringUtils; @@ -93,7 +94,9 @@ public class StatAgent if (category.getSoftwares().containsIgnoreCase(softwareName)) { stat.incServiceCount(); - stat.incUserCount(service.getUserCount()); + YearMonth month = YearMonth.now().minusMonths(1); + stat.incUserCount(service.getMonthUserCount(month)); + stat.incVisitCount(service.getMonthVisitCount(month)); organizations.add(service.getOrganization().getName()); } } @@ -201,7 +204,9 @@ public class StatAgent if (current == software) { stat.incServiceCount(); - stat.incUserCount(service.getUserCount()); + YearMonth month = YearMonth.now().minusMonths(1); + stat.incUserCount(service.getMonthUserCount(month)); + stat.incVisitCount(service.getMonthVisitCount(month)); organizations.add(service.getOrganization().getName()); } } diff --git a/src/fr/devinsy/statoolinfos/stats/categories/CategoryStat.java b/src/fr/devinsy/statoolinfos/stats/categories/CategoryStat.java index c9f0276..66c9925 100644 --- a/src/fr/devinsy/statoolinfos/stats/categories/CategoryStat.java +++ b/src/fr/devinsy/statoolinfos/stats/categories/CategoryStat.java @@ -29,6 +29,7 @@ public class CategoryStat private int serviceCount; private int organizationCount; private int userCount; + private int visitCount; /** * Instantiates a new category stat. @@ -42,6 +43,7 @@ public class CategoryStat this.serviceCount = 0; this.organizationCount = 0; this.userCount = 0; + this.visitCount = 0; } public Category getCategory() @@ -64,6 +66,11 @@ public class CategoryStat return this.userCount; } + public int getVisitCount() + { + return this.visitCount; + } + /** * Inc organization count. */ @@ -85,7 +92,7 @@ public class CategoryStat */ public void incUserCount() { - this.serviceCount += 1; + this.userCount += 1; } /** @@ -94,11 +101,30 @@ public class CategoryStat * @param value * the value */ - public void incUserCount(final int value) + public void incUserCount(final long value) { this.userCount += value; } + /** + * Inc visit count. + */ + public void incVisitCount() + { + this.visitCount += 1; + } + + /** + * Inc visit count. + * + * @param value + * the value + */ + public void incVisitCount(final long value) + { + this.visitCount += value; + } + public void setOrganizationCount(final int organizationCount) { this.organizationCount = organizationCount; @@ -113,4 +139,9 @@ public class CategoryStat { this.userCount = userCount; } + + public void setVisitCount(final int visitCount) + { + this.visitCount = visitCount; + } } diff --git a/src/fr/devinsy/statoolinfos/stats/softwares/SoftwareStat.java b/src/fr/devinsy/statoolinfos/stats/softwares/SoftwareStat.java index 2c9c82f..f081840 100644 --- a/src/fr/devinsy/statoolinfos/stats/softwares/SoftwareStat.java +++ b/src/fr/devinsy/statoolinfos/stats/softwares/SoftwareStat.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Christian Pierre MOMON + * Copyright (C) 2020-2022 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -27,10 +27,13 @@ import fr.devinsy.statoolinfos.core.StatoolInfosUtils; public class SoftwareStat { private String name; + private Categories categories; + private int serviceCount; private int organizationCount; private int userCount; + private int visitCount; /** * Instantiates a new software stat. @@ -87,6 +90,11 @@ public class SoftwareStat return this.userCount; } + public int getVisitCount() + { + return this.visitCount; + } + /** * Inc service count. */ @@ -109,11 +117,30 @@ public class SoftwareStat * @param value * the value */ - public void incUserCount(final int value) + public void incUserCount(final long value) { this.userCount += value; } + /** + * Inc visit count. + */ + public void incVisitCount() + { + this.visitCount += 1; + } + + /** + * Inc visit count. + * + * @param value + * the value + */ + public void incVisitCount(final long value) + { + this.visitCount += value; + } + public void setName(final String name) { this.name = name; @@ -133,4 +160,9 @@ public class SoftwareStat { this.userCount = userCount; } + + public void setVisitCount(final int visitCount) + { + this.visitCount = visitCount; + } }