Added service count chart and service date status chart.
This commit is contained in:
parent
5e4829d315
commit
e8be6ba8d1
7 changed files with 402 additions and 1 deletions
|
@ -192,7 +192,7 @@ public class StatoolInfosUtils
|
||||||
{
|
{
|
||||||
result = LocalDate.parse(date, DateTimeFormatter.ofPattern("dd/MM/yyyy"));
|
result = LocalDate.parse(date, DateTimeFormatter.ofPattern("dd/MM/yyyy"));
|
||||||
}
|
}
|
||||||
else if (date.matches("^\\d{4}-\\d{1,2}-\\d{1,2}/$"))
|
else if (date.matches("^\\d{4}-\\d{1,2}-\\d{1,2}$"))
|
||||||
{
|
{
|
||||||
result = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
result = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,8 @@ public class FederationStatsPage
|
||||||
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
|
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
|
||||||
|
|
||||||
TagDataManager data = new TagDataManager();
|
TagDataManager data = new TagDataManager();
|
||||||
|
data.setContent("serviceDateStatusChart", Htmlizer.htmlizeServiceDateStatusChart(federation.getAllServices()));
|
||||||
|
data.setContent("serviceCountChart", Htmlizer.htmlizeServiceCountChart(federation));
|
||||||
|
|
||||||
data.setContent("turnoutChart", Htmlizer.htmlizeOrganizationTurnoutChart(federation.getOrganizations()));
|
data.setContent("turnoutChart", Htmlizer.htmlizeOrganizationTurnoutChart(federation.getOrganizations()));
|
||||||
data.setContent("organizationCountryChart", Htmlizer.htmlizeOrganizationCountryChart(federation.getOrganizations()));
|
data.setContent("organizationCountryChart", Htmlizer.htmlizeOrganizationCountryChart(federation.getOrganizations()));
|
||||||
|
|
|
@ -20,6 +20,8 @@ package fr.devinsy.statoolinfos.htmlize;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.YearMonth;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -32,6 +34,7 @@ import fr.devinsy.statoolinfos.core.Configuration;
|
||||||
import fr.devinsy.statoolinfos.core.Federation;
|
import fr.devinsy.statoolinfos.core.Federation;
|
||||||
import fr.devinsy.statoolinfos.core.Organization;
|
import fr.devinsy.statoolinfos.core.Organization;
|
||||||
import fr.devinsy.statoolinfos.core.Organizations;
|
import fr.devinsy.statoolinfos.core.Organizations;
|
||||||
|
import fr.devinsy.statoolinfos.core.Service;
|
||||||
import fr.devinsy.statoolinfos.core.Services;
|
import fr.devinsy.statoolinfos.core.Services;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
import fr.devinsy.statoolinfos.core.StatoolInfosException;
|
||||||
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
|
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
|
||||||
|
@ -413,6 +416,65 @@ public class Htmlizer
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Htmlize service count chart.
|
||||||
|
*
|
||||||
|
* @param services
|
||||||
|
* the services
|
||||||
|
* @return the string
|
||||||
|
* @throws StatoolInfosException
|
||||||
|
* the statool infos exception
|
||||||
|
*/
|
||||||
|
public static String htmlizeServiceCountChart(final Federation federation) throws StatoolInfosException
|
||||||
|
{
|
||||||
|
String result;
|
||||||
|
|
||||||
|
BarChart chart;
|
||||||
|
|
||||||
|
chart = new BarChart("Nombre des services");
|
||||||
|
chart.addDataset("Services");
|
||||||
|
|
||||||
|
YearMonth now = YearMonth.now();
|
||||||
|
YearMonth current = YearMonth.from(StatoolInfosUtils.parseDate(federation.getStartDate()));
|
||||||
|
while (current.compareTo(now) <= 0)
|
||||||
|
{
|
||||||
|
long count = 0;
|
||||||
|
for (Service service : federation.getAllServices())
|
||||||
|
{
|
||||||
|
LocalDate startDate = StatoolInfosUtils.parseDate(service.getStartDate());
|
||||||
|
LocalDate endDate = StatoolInfosUtils.parseDate(service.getEndDate());
|
||||||
|
|
||||||
|
if (startDate != null)
|
||||||
|
{
|
||||||
|
YearMonth start = YearMonth.from(startDate);
|
||||||
|
YearMonth end;
|
||||||
|
if (endDate == null)
|
||||||
|
{
|
||||||
|
end = now;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
end = YearMonth.of(endDate.getYear(), endDate.getMonth());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((current.compareTo(start) >= 0) && (current.compareTo(end) <= 0))
|
||||||
|
{
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
chart.add(current.toString(), count, ChartColor.VIOLET);
|
||||||
|
|
||||||
|
current = current.plusMonths(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = BarChartView.build(chart);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Htmlize service country chart.
|
* Htmlize service country chart.
|
||||||
*
|
*
|
||||||
|
@ -457,6 +519,46 @@ public class Htmlizer
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Htmlize service date status chart.
|
||||||
|
*
|
||||||
|
* @param services
|
||||||
|
* the services
|
||||||
|
* @return the string
|
||||||
|
* @throws StatoolInfosException
|
||||||
|
* the statool infos exception
|
||||||
|
*/
|
||||||
|
public static String htmlizeServiceDateStatusChart(final Services services) throws StatoolInfosException
|
||||||
|
{
|
||||||
|
String result;
|
||||||
|
|
||||||
|
PieChart pie = new PieChart("Services avec dates");
|
||||||
|
|
||||||
|
long filled = 0;
|
||||||
|
long unfilled = 0;
|
||||||
|
for (Service service : services)
|
||||||
|
{
|
||||||
|
if (StatoolInfosUtils.parseDate(service.getStartDate()) == null)
|
||||||
|
{
|
||||||
|
unfilled += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filled += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pie.add("Avec", filled, ChartColor.VIOLET);
|
||||||
|
pie.add("Sans", unfilled, ChartColor.BLUE);
|
||||||
|
|
||||||
|
pie.setLegendPosition(Position.RIGHT);
|
||||||
|
|
||||||
|
result = PieChartView.build(pie);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Htmlize service install type chart.
|
* Htmlize service install type chart.
|
||||||
*
|
*
|
||||||
|
|
|
@ -15,6 +15,10 @@
|
||||||
|
|
||||||
<h2 id="title" class="center">Statistiques</h2>
|
<h2 id="title" class="center">Statistiques</h2>
|
||||||
<div>
|
<div>
|
||||||
|
<div>
|
||||||
|
<div id="serviceCountChart" class="chartborder" style="width: 500px; height: 200px; display: inline-block;"/>
|
||||||
|
<div id="serviceDateStatusChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div id="turnoutChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
<div id="turnoutChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
||||||
<div id="organizationCountryChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
<div id="organizationCountryChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
*/
|
*/
|
||||||
package fr.devinsy.statoolinfos.metrics;
|
package fr.devinsy.statoolinfos.metrics;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.YearMonth;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -104,6 +106,47 @@ public class TimeMark
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To string.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
String result;
|
||||||
|
|
||||||
|
result = this.value;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Day of.
|
||||||
|
*
|
||||||
|
* @param date
|
||||||
|
* the date
|
||||||
|
* @return the time mark
|
||||||
|
*/
|
||||||
|
public static TimeMark dayOf(final LocalDate date)
|
||||||
|
{
|
||||||
|
TimeMark result;
|
||||||
|
|
||||||
|
String day = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.FRANCE));
|
||||||
|
result = new TimeMark(day);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Day of.
|
||||||
|
*
|
||||||
|
* @param date
|
||||||
|
* the date
|
||||||
|
* @return the time mark
|
||||||
|
*/
|
||||||
public static TimeMark dayOf(final LocalDateTime date)
|
public static TimeMark dayOf(final LocalDateTime date)
|
||||||
{
|
{
|
||||||
TimeMark result;
|
TimeMark result;
|
||||||
|
@ -115,6 +158,24 @@ public class TimeMark
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Month of.
|
||||||
|
*
|
||||||
|
* @param date
|
||||||
|
* the date
|
||||||
|
* @return the time mark
|
||||||
|
*/
|
||||||
|
public static TimeMark monthOf(final LocalDate date)
|
||||||
|
{
|
||||||
|
TimeMark result;
|
||||||
|
|
||||||
|
String month = date.format(DateTimeFormatter.ofPattern("yyyy-MM", Locale.FRANCE));
|
||||||
|
result = new TimeMark(month);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Month of.
|
* Month of.
|
||||||
*
|
*
|
||||||
|
@ -133,6 +194,42 @@ public class TimeMark
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Month of.
|
||||||
|
*
|
||||||
|
* @param date
|
||||||
|
* the date
|
||||||
|
* @return the time mark
|
||||||
|
*/
|
||||||
|
public static TimeMark monthOf(final YearMonth date)
|
||||||
|
{
|
||||||
|
TimeMark result;
|
||||||
|
|
||||||
|
String month = date.format(DateTimeFormatter.ofPattern("yyyy-MM", Locale.FRANCE));
|
||||||
|
result = new TimeMark(month);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Year of.
|
||||||
|
*
|
||||||
|
* @param date
|
||||||
|
* the date
|
||||||
|
* @return the time mark
|
||||||
|
*/
|
||||||
|
public static TimeMark yearOf(final LocalDate date)
|
||||||
|
{
|
||||||
|
TimeMark result;
|
||||||
|
|
||||||
|
String year = date.format(DateTimeFormatter.ofPattern("yyyy", Locale.FRANCE));
|
||||||
|
result = new TimeMark(year);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Year of.
|
* Year of.
|
||||||
*
|
*
|
||||||
|
@ -151,6 +248,24 @@ public class TimeMark
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Year week of.
|
||||||
|
*
|
||||||
|
* @param date
|
||||||
|
* the date
|
||||||
|
* @return the time mark
|
||||||
|
*/
|
||||||
|
public static TimeMark yearWeekOf(final LocalDate date)
|
||||||
|
{
|
||||||
|
TimeMark result;
|
||||||
|
|
||||||
|
String yearWeek = date.format(DateTimeFormatter.ofPattern("yyyyWW", Locale.FRANCE));
|
||||||
|
result = new TimeMark(yearWeek);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Year week of.
|
* Year week of.
|
||||||
*
|
*
|
||||||
|
|
71
src/fr/devinsy/statoolinfos/metrics/TimeMarkCounters.java
Normal file
71
src/fr/devinsy/statoolinfos/metrics/TimeMarkCounters.java
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
|
||||||
|
*
|
||||||
|
* This file is part of StatoolInfos, simple service statistics tool.
|
||||||
|
*
|
||||||
|
* StatoolInfos is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* StatoolInfos is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package fr.devinsy.statoolinfos.metrics;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class TimeMarkCounters.
|
||||||
|
*/
|
||||||
|
public class TimeMarkCounters extends HashMap<String, Long>
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = -3437543089769867597L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new time mark counters.
|
||||||
|
*/
|
||||||
|
public TimeMarkCounters()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the.
|
||||||
|
*
|
||||||
|
* @param timeMark
|
||||||
|
* the time mark
|
||||||
|
* @return the long
|
||||||
|
*/
|
||||||
|
public Long get(final String timeMark)
|
||||||
|
{
|
||||||
|
Long result;
|
||||||
|
|
||||||
|
result = super.get(timeMark);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inc.
|
||||||
|
*
|
||||||
|
* @param timemark
|
||||||
|
* the timemark
|
||||||
|
*/
|
||||||
|
public void inc(final String timemark)
|
||||||
|
{
|
||||||
|
Long value = super.get(timemark);
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
value = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
put(timemark, value + 1);
|
||||||
|
}
|
||||||
|
}
|
107
src/fr/devinsy/statoolinfos/metrics/YearMonthCounters.java
Normal file
107
src/fr/devinsy/statoolinfos/metrics/YearMonthCounters.java
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
|
||||||
|
*
|
||||||
|
* This file is part of StatoolInfos, simple service statistics tool.
|
||||||
|
*
|
||||||
|
* StatoolInfos is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* StatoolInfos is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package fr.devinsy.statoolinfos.metrics;
|
||||||
|
|
||||||
|
import java.time.YearMonth;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class YearMonthCounters.
|
||||||
|
*/
|
||||||
|
public class YearMonthCounters extends HashMap<YearMonth, Long>
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 2707786945149971666L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new year month counters.
|
||||||
|
*/
|
||||||
|
public YearMonthCounters()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the.
|
||||||
|
*
|
||||||
|
* @param timemark
|
||||||
|
* the timemark
|
||||||
|
* @return the long
|
||||||
|
*/
|
||||||
|
public long get(final YearMonth timemark)
|
||||||
|
{
|
||||||
|
long result;
|
||||||
|
|
||||||
|
Long value = super.get(timemark);
|
||||||
|
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
result = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the first.
|
||||||
|
*
|
||||||
|
* @return the first
|
||||||
|
*/
|
||||||
|
public YearMonth getFirstTimeMark()
|
||||||
|
{
|
||||||
|
YearMonth result;
|
||||||
|
|
||||||
|
result = null;
|
||||||
|
Iterator<YearMonth> iterator = keySet().iterator();
|
||||||
|
while (iterator.hasNext())
|
||||||
|
{
|
||||||
|
YearMonth current = iterator.next();
|
||||||
|
|
||||||
|
if ((result == null) || (current.isBefore(result)))
|
||||||
|
{
|
||||||
|
result = current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inc.
|
||||||
|
*
|
||||||
|
* @param timemark
|
||||||
|
* the timemark
|
||||||
|
*/
|
||||||
|
public void inc(final YearMonth timemark)
|
||||||
|
{
|
||||||
|
Long value = super.get(timemark);
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
value = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
put(timemark, value + 1);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue