Refactored stats and metrics for organization and service.

This commit is contained in:
Christian P. MOMON 2021-05-29 02:23:15 +02:00
parent 8f03507fb0
commit f179c75281
18 changed files with 355 additions and 57 deletions

View file

@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfos;
import fr.devinsy.statoolinfos.util.BuildInformation;
import fr.devinsy.statoolinfos.util.Chrono;
import fr.devinsy.statoolinfos.util.Files;
import fr.devinsy.statoolinfos.util.FilesUtils;
import fr.devinsy.strings.StringList;
@ -262,6 +263,7 @@ public final class StatoolInfosCLI
}
else if (isMatching(args, "crawl", "\\s*.+\\s*"))
{
Chrono chrono = new Chrono().start();
Files inputs = convertPath(StringUtils.trim(args[1]));
for (File input : inputs)
{
@ -275,6 +277,7 @@ public final class StatoolInfosCLI
exception.printStackTrace();
}
}
System.out.println(chrono.format());
}
else if (isMatching(args, "format", "\\s*.+\\s*"))
{
@ -294,6 +297,7 @@ public final class StatoolInfosCLI
}
else if (isMatching(args, "htmlize", "\\s*.+\\s*"))
{
Chrono chrono = new Chrono().start();
Files inputs = convertPath(StringUtils.trim(args[1]));
for (File input : inputs)
{
@ -307,6 +311,7 @@ public final class StatoolInfosCLI
exception.printStackTrace();
}
}
System.out.println(chrono.format());
}
else if (isMatching(args, "probe", "\\s*.+\\s*"))
{

View file

@ -99,6 +99,7 @@ public class OrganizationHeaderView
data.setAttribute("rawCheckLink", "href", organization.getTechnicalName() + "-check.xhtml");
data.setAttribute("statsLink", "href", organization.getTechnicalName() + "-stats.xhtml");
data.setAttribute("metricsLink", "href", organization.getTechnicalName() + "-metrics.xhtml");
data.setAttribute("crawlLink", "href", organization.getTechnicalName() + "-crawl.xhtml");
if (organization.getCrawlJournal().getErrors().isEmpty())

View file

@ -37,7 +37,6 @@ public class OrganizationMetricMenuView
public enum MenuItem
{
GENERAL,
SUMMARY,
GENERIC,
WEB,
@ -61,17 +60,12 @@ public class OrganizationMetricMenuView
{
TagDataManager data = new TagDataManager();
data.setAttribute("generalTypeButton", "href", organization.getTechnicalName() + "-stats.xhtml");
data.setAttribute("summaryTypeButton", "href", organization.getTechnicalName() + "-stats-summarymetrics.xhtml");
data.setAttribute("genericTypeButton", "href", organization.getTechnicalName() + "-stats-genericmetrics.xhtml");
data.setAttribute("webTypeButton", "href", organization.getTechnicalName() + "-stats-webmetrics.xhtml");
data.setAttribute("specificTypeButton", "href", organization.getTechnicalName() + "-stats-specificmetrics.xhtml");
data.setAttribute("summaryTypeButton", "href", organization.getTechnicalName() + "-metrics.xhtml");
data.setAttribute("genericTypeButton", "href", organization.getTechnicalName() + "-metrics-generic.xhtml");
data.setAttribute("webTypeButton", "href", organization.getTechnicalName() + "-metrics-web.xhtml");
data.setAttribute("specificTypeButton", "href", organization.getTechnicalName() + "-metrics-specific.xhtml");
if ((item == null) || (item == MenuItem.GENERAL))
{
data.appendAttribute("generalTypeButton", "class", "button selected");
}
else if (item == MenuItem.SUMMARY)
if ((item == null) || (item == MenuItem.SUMMARY))
{
data.appendAttribute("summaryTypeButton", "class", "button selected");
}

View file

@ -78,20 +78,20 @@ public class OrganizationPage
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats.xhtml"), page, StandardCharsets.UTF_8);
logger.info("Htmlize organization summarty metric page: {}.", organization.getName());
page = OrganizationSummaryStatsPage.htmlize(organization);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-summarymetrics.xhtml"), page, StandardCharsets.UTF_8);
page = OrganizationSummaryMetricPage.htmlize(organization);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-metrics.xhtml"), page, StandardCharsets.UTF_8);
logger.info("Htmlize organization generic metric page: {}.", organization.getName());
page = OrganizationGenericMetricPage.htmlize(organization);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-genericmetrics.xhtml"), page, StandardCharsets.UTF_8);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-metrics-generic.xhtml"), page, StandardCharsets.UTF_8);
logger.info("Htmlize organization web metric page: {}.", organization.getName());
page = OrganizationWebMetricPage.htmlize(organization);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-webmetrics.xhtml"), page, StandardCharsets.UTF_8);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-metrics-web.xhtml"), page, StandardCharsets.UTF_8);
logger.info("Htmlize service specific metric page: {}.", organization.getName());
page = OrganizationSpecificMetricPage.htmlize(organization);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-stats-specificmetrics.xhtml"), page, StandardCharsets.UTF_8);
FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-metrics-specific.xhtml"), page, StandardCharsets.UTF_8);
}
/**

View file

@ -18,16 +18,13 @@
*/
package fr.devinsy.statoolinfos.htmlize;
import java.io.File;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.OrganizationMetricMenuView.MenuItem;
import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.stats.services.RegistrationStats;
import fr.devinsy.xidyn.XidynException;
@ -60,13 +57,10 @@ public class OrganizationStatsPage
{
logger.debug("Building organization stats page {}…");
File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory();
TagDataManager data = new TagDataManager();
//
data.setContent("headerView", OrganizationHeaderView.htmlize(organization));
data.setContent("metricMenuView", OrganizationMetricMenuView.htmlize(organization, MenuItem.GENERAL));
//
data.setContent("serviceCountYearChart", ChartHtmlizer.htmlizeServiceCountYearChart(organization));
@ -91,7 +85,7 @@ public class OrganizationStatsPage
}
//
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationStatsView.xhtml", data).toString();
String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organizationStatsPage.xhtml", data).toString();
//
BreadcrumbTrail trail = new BreadcrumbTrail();

View file

@ -38,9 +38,9 @@ import fr.devinsy.xidyn.presenters.PresenterUtils;
/**
* The Class OrganizationGeneralStatsPage.
*/
public class OrganizationSummaryStatsPage
public class OrganizationSummaryMetricPage
{
private static Logger logger = LoggerFactory.getLogger(OrganizationSummaryStatsPage.class);
private static Logger logger = LoggerFactory.getLogger(OrganizationSummaryMetricPage.class);
/**
* Htmlize.

View file

@ -86,6 +86,7 @@ public class ServiceHeaderView
data.setAttribute("rawCheckLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-check.xhtml");
data.setAttribute("statsLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
data.setAttribute("metricsLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics.xhtml");
if (StringUtils.isNotBlank(service.getLegalWebsite()))
{

View file

@ -37,7 +37,6 @@ public class ServiceMetricMenuView
public enum MenuItem
{
GENERAL,
SUMMARY,
WEB,
GENERIC,
@ -61,17 +60,12 @@ public class ServiceMetricMenuView
{
TagDataManager data = new TagDataManager();
data.setAttribute("generalTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml");
data.setAttribute("summaryTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-summarymetrics.xhtml");
data.setAttribute("genericTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-genericmetrics.xhtml");
data.setAttribute("webTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-webmetrics.xhtml");
data.setAttribute("specificTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-stats-specificmetrics.xhtml");
data.setAttribute("summaryTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics.xhtml");
data.setAttribute("genericTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-generic.xhtml");
data.setAttribute("webTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-web.xhtml");
data.setAttribute("specificTypeButton", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-metrics-specific.xhtml");
if ((item == null) || (item == MenuItem.GENERAL))
{
data.appendAttribute("generalTypeButton", "class", "button selected");
}
else if (item == MenuItem.SUMMARY)
if ((item == null) || (item == MenuItem.SUMMARY))
{
data.appendAttribute("summaryTypeButton", "class", "button selected");
}

View file

@ -78,20 +78,20 @@ public class ServicePage
//
logger.info("Htmlize service summary metric page: {}.", service.getName());
page = ServiceSummaryMetricPage.htmlize(service);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-summarymetrics.xhtml"), page, StandardCharsets.UTF_8);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics.xhtml"), page, StandardCharsets.UTF_8);
//
logger.info("Htmlize service generic metric page: {}.", service.getName());
page = ServiceGenericMetricPage.htmlize(service);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-genericmetrics.xhtml"), page, StandardCharsets.UTF_8);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-generic.xhtml"), page, StandardCharsets.UTF_8);
logger.info("Htmlize service web metric page: {}.", service.getName());
page = ServiceWebMetricPage.htmlize(service);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-webmetrics.xhtml"), page, StandardCharsets.UTF_8);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-web.xhtml"), page, StandardCharsets.UTF_8);
logger.info("Htmlize service specific metric page: {}.", service.getName());
page = ServiceSpecificMetricPage.htmlize(service);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-stats-specificmetrics.xhtml"), page, StandardCharsets.UTF_8);
FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-metrics-specific.xhtml"), page, StandardCharsets.UTF_8);
}
/**

View file

@ -24,7 +24,6 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.htmlize.ServiceMetricMenuView.MenuItem;
import fr.devinsy.statoolinfos.stats.StatAgent;
import fr.devinsy.statoolinfos.stats.services.RegistrationStats;
import fr.devinsy.xidyn.XidynException;
@ -58,9 +57,6 @@ public class ServiceStatsView
TagDataManager data = new TagDataManager();
//
data.setContent("metricMenuView", ServiceMetricMenuView.htmlize(service, MenuItem.GENERAL));
//
data.setContent("turnoutChart", ChartHtmlizer.htmlizeOrganizationTurnoutChart(service));

View file

@ -14,7 +14,6 @@
<div>
<div style="margin: 5px;">
<span style="display: inline-block; width: 100px">Type</span>
<a onclick="javascript:selectTypeMenu('general');" href="#" id="generalTypeButton" class="button">Général</a>
<a onclick="javascript:selectTypeMenu('summary');" href="#" id="summaryTypeButton" class="button">Résumé</a>
<a onclick="javascript:selectTypeMenu('generic');" href="#" id="genericTypeButton" class="button">Génériques</a>
<a onclick="javascript:selectTypeMenu('web');" href="#" id="webTypeButton" class="button">Web</a>
@ -22,7 +21,7 @@
</div>
<div style="margin: 5px;">
<span style="display: inline-block; width: 100px">Période</span>
<a onclick="javascript:selectPeriodMenu('full');" href="#" id="fullPeriodButton" class="button">Full</a>
<a onclick="javascript:selectPeriodMenu('full');" href="#" id="fullPeriodButton" class="button">Tout</a>
<a onclick="javascript:selectPeriodMenu('last');" href="#" id="lastPeriodButton" class="button selected">12 mois</a>
<a onclick="javascript:selectPeriodMenu('2020');" href="#" id="2020PeriodButton" class="button">2020</a>
<a onclick="javascript:selectPeriodMenu('2021');" href="#" id="2021PeriodButton" class="button">2021</a>
@ -40,7 +39,6 @@
function selectTypeMenu(selection)
{
document.getElementById ('summaryTypeButton').classList.remove('selected');
document.getElementById ('generalTypeButton').classList.remove('selected');
document.getElementById ('genericTypeButton').classList.remove('selected');
document.getElementById ('webTypeButton').classList.remove('selected');
document.getElementById ('specificTypeButton').classList.remove('selected');
@ -53,10 +51,6 @@ function selectTypeMenu(selection)
{
document.getElementById ('genericTypeButton').classList.add('selected');
}
else if (selection == 'general')
{
document.getElementById ('generalTypeButton').classList.add('selected');
}
else if (selection == 'web')
{
document.getElementById ('webTypeButton').classList.add('selected');

View file

@ -34,7 +34,8 @@
<a id="rawCheckLink" href="#"><img id="rawCheckLinkImg" src="circle-icons/clipboard-mono.svg" title="Fichier propriétés analysé"/></a>
<a id="rawLink" href="#"><img id="rawLinkImg" src="circle-icons/document-mono.svg" title="Fichier propriétés"/></a>
<a id="crawlLink" href="#"><img id="crawlLinkImg" src="circle-icons/download-mono.svg" title="Statut des téléchargements"/></a>
<a id="statsLink" href="#"><img id="statsLinkImg" src="circle-icons/barchart-mono.svg" title="Statistiques"/></a>
<a id="statsLink" href="#"><img id="statsLinkImg" src="circle-icons/piechart-mono.svg" title="Statistiques"/></a>
<a id="metricsLink" href="#"><img id="metricsLinkImg" src="circle-icons/barchart-mono.svg" title="Métriques"/></a>
<div style="display: inline-block; vertical-align: middle; font-size: smaller; margin-left: 2px; width: 35px;">
<a id="alertLink" href="#" style="text-decoration: none;">
<div id="errorCount" class="bg_error center" title="Propriétés en erreurs">n/a</div>

View file

@ -12,9 +12,8 @@
</head>
<body>
<div id="headerView" />
<div id="metricMenuView" />
<div id="metricZone" class="row center_table" style="width: 1100px;">
<!-- h2 id="title" class="center">Statistiques</h2-->
<h2 id="title" class="center">Statistiques</h2>
<div>
<div>
<div id="turnoutChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>

View file

@ -42,7 +42,8 @@
<a id="rawCheckLink" href="#"><img id="rawCheckLinkImg" src="circle-icons/clipboard-mono.svg" title="Fichier propriétés analysé"/></a>
<a id="rawLink" href="#"><img id="rawLinkImg" src="circle-icons/document-mono.svg" title="Fichier propriétés"/></a>
<a id="crawlLink" href="#"><img id="crawlLinkImg" src="circle-icons/download-mono.svg" title="Statut des téléchargements"/></a>
<a id="statsLink" href="#"><img id="statsLinkImg" src="circle-icons/barchart-mono.svg" title="Statistiques"/></a>
<a id="statsLink" href="#"><img id="statsLinkImg" src="circle-icons/piechart-mono.svg" title="Statistiques"/></a>
<a id="metricsLink" href="#"><img id="metricsLinkImg" src="circle-icons/barchart-mono.svg" title="Métriques"/></a>
<div style="display: inline-block; vertical-align: middle; font-size: smaller; margin-left: 2px; width: 35px;">
<a id="alertLink" href="#" style="text-decoration: none;">
<div id="errorCount" class="bg_error center" title="Propriétés en erreurs">n/a</div>

View file

@ -11,9 +11,8 @@
<script src="Chart.bundle.min.js"></script>
</head>
<body>
<div id="metricMenuView" />
<div id="metricZone" class="row center_table" style="width: 1100px;">
<!-- h2 id="title" class="center">Statistiques</h2-->
<h2 id="title" class="center">Statistiques</h2>
<div>
<div id="turnoutChart" class="chartborder" style="width: 250px; height: 200px; display: inline-block;"/>
</div>

View file

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="svg2"
xml:space="preserve"
width="85.333336"
height="85.333336"
viewBox="0 0 85.333336 85.333336"
sodipodi:docname="pie-chart.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"><metadata
id="metadata8"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs6"><clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath18"><path
d="M 0,64 H 64 V 0 H 0 Z"
id="path16"
inkscape:connector-curvature="0" /></clipPath></defs><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview4"
showgrid="false"
inkscape:zoom="2.7656249"
inkscape:cx="42.666668"
inkscape:cy="42.666668"
inkscape:window-x="0"
inkscape:window-y="25"
inkscape:window-maximized="0"
inkscape:current-layer="g10" /><g
id="g10"
inkscape:groupmode="layer"
inkscape:label="Elegant_circle-icons"
transform="matrix(1.3333333,0,0,-1.3333333,0,85.333333)"><g
id="g12"><g
id="g14"
clip-path="url(#clipPath18)"><g
id="g20"
transform="translate(35,55)"><path
d="M 0,0 V -20 H 20 C 20,-8.954 11.046,0 0,0"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path22"
inkscape:connector-curvature="0" /></g><g
id="g24"
transform="translate(31,53)"><path
d="m 0,0 c -12.15,0 -22,-9.85 -22,-22 0,-12.15 9.85,-22 22,-22 5.692,0 10.88,2.162 14.786,5.71 C 19.217,-34.266 22,-28.458 22,-22 H 0 Z"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path26"
inkscape:connector-curvature="0" /></g><g
id="g28"
transform="translate(35,35)"><path
d="M 0,0 V 20 C 11.046,20 20,11.046 20,0 Z M 10.786,-20.29 C 6.88,-23.838 1.692,-26 -4,-26 c -12.15,0 -22,9.85 -22,22 0,12.15 9.85,22 22,22 V -4 h 22 c 0,-6.458 -2.783,-12.266 -7.214,-16.29 M -3,29 c -17.673,0 -32,-14.327 -32,-32 0,-17.673 14.327,-32 32,-32 17.673,0 32,14.327 32,32 0,17.673 -14.327,32 -32,32"
style="fill:#4f5d73;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path30"
inkscape:connector-curvature="0" /></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="svg2"
xml:space="preserve"
width="85.333336"
height="85.333336"
viewBox="0 0 85.333336 85.333336"
sodipodi:docname="pie.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"><metadata
id="metadata8"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs6"><clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath18"><path
d="M 0,64 H 64 V 0 H 0 Z"
id="path16"
inkscape:connector-curvature="0" /></clipPath><clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath30"><path
d="M 35,53 H 55 V 33 H 35 Z"
id="path28"
inkscape:connector-curvature="0" /></clipPath><clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath50"><path
d="M 9,51 H 45.7859 V 7 H 9 Z"
id="path48"
inkscape:connector-curvature="0" /></clipPath><clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath70"><path
d="M 31,31 H 53 V 12.7097 H 31 Z"
id="path68"
inkscape:connector-curvature="0" /></clipPath></defs><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview4"
showgrid="false"
inkscape:zoom="2.7656249"
inkscape:cx="42.666668"
inkscape:cy="42.666668"
inkscape:window-x="256"
inkscape:window-y="124"
inkscape:window-maximized="0"
inkscape:current-layer="g10" /><g
id="g10"
inkscape:groupmode="layer"
inkscape:label="Elegant_circle-icons"
transform="matrix(1.3333333,0,0,-1.3333333,0,85.333333)"><g
id="g12"><g
id="g14"
clip-path="url(#clipPath18)"><g
id="g20"
transform="translate(64,32)"><path
d="m 0,0 c 0,-17.673 -14.327,-32 -32,-32 -17.673,0 -32,14.327 -32,32 0,17.673 14.327,32 32,32 C -14.327,32 0,17.673 0,0"
style="fill:#e0e0d1;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path22"
inkscape:connector-curvature="0" /></g><g
id="g24"><g
id="g26" /><g
id="g38"><g
clip-path="url(#clipPath30)"
id="g36"
style="opacity:0.19999701"><g
transform="translate(55,33)"
id="g34"><path
d="M 0,0 C 0,11.046 -8.954,20 -20,20 V 0 Z"
style="fill:#231f20;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path32"
inkscape:connector-curvature="0" /></g></g></g></g><g
id="g40"
transform="translate(55,35)"><path
d="M 0,0 C 0,11.046 -8.954,20 -20,20 V 0 Z"
style="fill:#4f5d73;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path42"
inkscape:connector-curvature="0" /></g><g
id="g44"><g
id="g46" /><g
id="g58"><g
clip-path="url(#clipPath50)"
id="g56"
style="opacity:0.19999701"><g
transform="translate(31,51)"
id="g54"><path
d="m 0,0 c -12.15,0 -22,-9.85 -22,-22 0,-12.15 9.85,-22 22,-22 5.692,0 10.88,2.162 14.786,5.71 L 0,-22 Z"
style="fill:#231f20;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path52"
inkscape:connector-curvature="0" /></g></g></g></g><g
id="g60"
transform="translate(31,53)"><path
d="m 0,0 c -12.15,0 -22,-9.85 -22,-22 0,-12.15 9.85,-22 22,-22 5.692,0 10.88,2.162 14.786,5.71 L 0,-22 Z"
style="fill:#76c2af;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path62"
inkscape:connector-curvature="0" /></g><g
id="g64"><g
id="g66" /><g
id="g78"><g
clip-path="url(#clipPath70)"
id="g76"
style="opacity:0.19999701"><g
transform="translate(53,31)"
id="g74"><path
d="M 0,0 H -22 V -2 L -7.214,-18.29 C -2.783,-14.266 0,-6.458 0,0"
style="fill:#231f20;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path72"
inkscape:connector-curvature="0" /></g></g></g></g><g
id="g80"
transform="translate(53,31)"><path
d="M 0,0 H -22 L -7.214,-16.29 C -2.783,-12.266 0,-6.458 0,0"
style="fill:#c75c5c;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path82"
inkscape:connector-curvature="0" /></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 5.3 KiB

View file

@ -0,0 +1,118 @@
/*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of Logar, simple tool to manage http log files.
*
* Logar 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.
*
* Logar 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 Logar. If not, see <http://www.gnu.org/licenses/>.
*/
package fr.devinsy.statoolinfos.util;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
/**
* The Class Chrono.
*/
public class Chrono
{
private LocalDateTime start;
/**
* Instantiates a new time keeper.
*/
public Chrono()
{
reset();
}
/**
* Duration.
*
* @return the long
*/
public long duration()
{
long result;
result = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC) - this.start.toEpochSecond(ZoneOffset.UTC);
//
return result;
}
/**
* Format.
*
* @return the string
*/
public String format()
{
String result;
if (this.start == null)
{
result = "n/a";
}
else
{
LocalDateTime end = LocalDateTime.now();
Duration duration = Duration.between(this.start, end);
result = String.format("%02d:%02d:%02d", duration.getSeconds() / 60 / 60, duration.getSeconds() / 60, duration.getSeconds() % 60);
}
//
return result;
}
/**
* Reset.
*/
public void reset()
{
this.start = null;
}
/**
* Start.
*/
public Chrono start()
{
Chrono result;
this.start = LocalDateTime.now();
result = this;
//
return result;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString()
{
String result;
result = format();
//
return result;
}
}