Added emoji, userCount, visitCount and column sorting.

This commit is contained in:
Christian P. MOMON 2022-03-04 18:23:01 +01:00
parent b731b9ad90
commit 94f807dfad
7 changed files with 168 additions and 24 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
*
* 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;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
*
* 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;
}

View file

@ -15,7 +15,7 @@
<div class="center" >
<h2>Catégories</h2>
<div>Nombre de catégories : <span id="categoryCount">n/a</span></div>
<div><span id="categoryCount">n/a</span> catégories</div>
</div>
<table id="categoryList" class="table_classic left">
<thead>
@ -25,6 +25,7 @@
<th class="" style="width: 100px;">Services</th>
<th class="" style="width: 100px;">Organisations</th>
<th class="" style="width: 100px;">Utilisateurs mensuels</th>
<th class="" style="width: 100px;">Visites mensuelles</th>
</tr>
</thead>
<tbody>
@ -39,17 +40,52 @@
<td id="categoryListLineServiceCount" class="td_number">n/a</td>
<td id="categoryListLineOrganizationCount" class="td_number">n/a</td>
<td id="categoryListLineUserCount" class="td_number">n/a</td>
<td id="categoryListLineVisitCount" class="td_number">n/a</td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript">
$('#categoryList').DataTable(
$(document).ready(function()
{
paging: false,
ordering: true,
"order": [[ 0, "asc" ]],
language: dataTableFrench
$.extend($.fn.dataTable.ext.type.order,
{
"custom-sort-asc": function(x, y)
{
if (!(!isNaN(x) || !isNaN(y)))
return 0;
else if (isNaN(x))
return -1;
else if (isNaN(y))
return +1;
else
return x-y;
},
"custom-sort-desc": function(x, y)
{
if (!(!isNaN(x) || !isNaN(y)))
return 0;
else if (isNaN(x))
return +1;
else if (isNaN(y))
return -1;
else
return y-x;
}
});
$('#categoryList').DataTable(
{
paging: false,
ordering: true,
"order": [[ 0, "asc" ]],
language: dataTableFrench,
"columnDefs":
[
{ targets: 4, "type": 'custom-sort' },
{ targets: 5, "type": 'custom-sort' }
]
});
});
</script>
</body>

View file

@ -15,7 +15,7 @@
<div class="center">
<h2>Logiciels</h2>
<div>Nombre de logiciels : <span id="softwareCount">n/a</span></div>
<div><span id="softwareCount">n/a</span> logiciels</div>
</div>
<table id="softwareList" class="table_classic left">
<thead>
@ -25,6 +25,7 @@
<th class="" style="width: 100px;">Services</th>
<th class="" style="width: 100px;">Organisations</th>
<th class="" style="width: 100px;">Utilisateurs mensuels</th>
<th class="" style="width: 100px;">Visites mensuelles</th>
</tr>
</thead>
<tbody>
@ -36,17 +37,52 @@
<td id="softwareListLineServiceCount" class="td_number">n/a</td>
<td id="softwareListLineOrganizationCount" class="td_number">n/a</td>
<td id="softwareListLineUserCount" class="td_number">n/a</td>
<td id="softwareListLineVisitCount" class="td_number">n/a</td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript">
$('#softwareList').DataTable(
$(document).ready(function()
{
paging: false,
ordering: true,
"order": [[ 0, "asc" ]],
language: dataTableFrench
$.extend($.fn.dataTable.ext.type.order,
{
"custom-sort-asc": function(x, y)
{
if (!(!isNaN(x) || !isNaN(y)))
return 0;
else if (isNaN(x))
return -1;
else if (isNaN(y))
return +1;
else
return x-y;
},
"custom-sort-desc": function(x, y)
{
if (!(!isNaN(x) || !isNaN(y)))
return 0;
else if (isNaN(x))
return +1;
else if (isNaN(y))
return -1;
else
return y-x;
}
} );
$('#softwareList').DataTable(
{
paging: false,
ordering: true,
"order": [[ 0, "asc" ]],
language: dataTableFrench,
"columnDefs":
[
{ targets: 4, "type": 'custom-sort' },
{ targets: 5, "type": 'custom-sort' }
]
});
});
</script>
</body>

View file

@ -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());
}
}

View file

@ -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;
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
*
* 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;
}
}