Added visit count and user count in federation page.

This commit is contained in:
Christian P. MOMON 2021-06-03 04:50:51 +02:00
parent 6ea3e87cec
commit 6cfc5a9184
5 changed files with 124 additions and 0 deletions

View file

@ -585,6 +585,44 @@ public class Organization extends PathPropertyList
return result; return result;
} }
/**
* Gets the previous month user count.
*
* @return the previous month user count
*/
public long getPreviousMonthUserCount()
{
long result;
result = 0;
for (Service service : this.services)
{
result += service.getPreviousMonthUserCount();
}
//
return result;
}
/**
* Gets the previous month visit count.
*
* @return the previous month visit count
*/
public long getPreviousMonthVisitCount()
{
long result;
result = 0;
for (Service service : this.services)
{
result += service.getPreviousMonthVisitCount();
}
//
return result;
}
/** /**
* Gets the service count. * Gets the service count.
* *

View file

@ -23,6 +23,7 @@ import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.YearMonth;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -31,6 +32,7 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.checker.PropertyChecks; import fr.devinsy.statoolinfos.checker.PropertyChecks;
import fr.devinsy.statoolinfos.crawl.CrawlJournal; import fr.devinsy.statoolinfos.crawl.CrawlJournal;
import fr.devinsy.statoolinfos.htmlize.charts.MonthValues;
import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathProperties;
import fr.devinsy.statoolinfos.properties.PathPropertyList; import fr.devinsy.statoolinfos.properties.PathPropertyList;
@ -473,11 +475,54 @@ public class Service extends PathPropertyList
return result; return result;
} }
/**
* Gets the organization.
*
* @return the organization
*/
public Organization getOrganization() public Organization getOrganization()
{ {
return this.organization; return this.organization;
} }
/**
* Gets the previous month user count.
*
* @return the previous month user count
*/
public long getPreviousMonthUserCount()
{
long result;
MonthValues values = getMetricMonthValues("metrics.users.count");
values = values.extract(YearMonth.now().minusMonths(1), YearMonth.now().minusMonths(1));
result = (long) values.sum();
//
return result;
}
/**
* Gets the previous month visit count.
*
* @return the previous month visit count
*/
public long getPreviousMonthVisitCount()
{
long result;
MonthValues values = getMetricMonthValues("metrics.http.visits.visitors");
values = values.extract(YearMonth.now().minusMonths(1), YearMonth.now().minusMonths(1));
result = (long) values.sum();
//
return result;
}
/** /**
* Gets the registration load. * Gets the registration load.
* *

View file

@ -129,6 +129,26 @@ public class FederationPage
data.setContent("organizationListLine", index, "organizationListLineServiceCount", organization.getServiceCount()); data.setContent("organizationListLine", index, "organizationListLineServiceCount", organization.getServiceCount());
long count = organization.getPreviousMonthUserCount();
if (count == 0)
{
data.setContent("organizationListLine", index, "organizationListLineUserCount", "n/a");
}
else
{
data.setContent("organizationListLine", index, "organizationListLineUserCount", count);
}
count = organization.getPreviousMonthVisitCount();
if (count == 0)
{
data.setContent("organizationListLine", index, "organizationListLineVisitCount", "n/a");
}
else
{
data.setContent("organizationListLine", index, "organizationListLineVisitCount", count);
}
data.setContent("organizationListLine", index, "organizationListLineDate", organization.getCrawledDate().format(DateTimeFormatter.ofPattern("dd/MM/YYYY"))); data.setContent("organizationListLine", index, "organizationListLineDate", organization.getCrawledDate().format(DateTimeFormatter.ofPattern("dd/MM/YYYY")));
data.setAttribute("organizationListLine", index, "organizationListLineDate", "title", organization.getCrawledDate().format(DateTimeFormatter.ofPattern("HH:mm:ss"))); data.setAttribute("organizationListLine", index, "organizationListLineDate", "title", organization.getCrawledDate().format(DateTimeFormatter.ofPattern("HH:mm:ss")));

View file

@ -281,6 +281,25 @@ public class MonthValues extends HashMap<YearMonth, Double>
this.label = label; this.label = label;
} }
/**
* Sum.
*
* @return the double
*/
public double sum()
{
double result;
result = 0;
for (Double value : this.values())
{
result += value;
}
//
return result;
}
/** /**
* Gets the normalized values. * Gets the normalized values.
* *

View file

@ -23,6 +23,7 @@
<th style="width: 250px;">URL</th> <th style="width: 250px;">URL</th>
<th style="width: 10px;">Services</th> <th style="width: 10px;">Services</th>
<th style="width: 10px;">Utilisateurs mensuels</th> <th style="width: 10px;">Utilisateurs mensuels</th>
<th style="width: 10px;">Visites mensuelles</th>
<th style="width: 10px;">Date</th> <th style="width: 10px;">Date</th>
</tr> </tr>
</thead> </thead>
@ -37,6 +38,7 @@
<td id="organizationListLineUrl"><a href="#" id="organizationListLineUrlLink">n/a</a></td> <td id="organizationListLineUrl"><a href="#" id="organizationListLineUrlLink">n/a</a></td>
<td id="organizationListLineServiceCount" class="td_number">n/a</td> <td id="organizationListLineServiceCount" class="td_number">n/a</td>
<td id="organizationListLineUserCount" class="td_number">n/a</td> <td id="organizationListLineUserCount" class="td_number">n/a</td>
<td id="organizationListLineVisitCount" class="td_number">n/a</td>
<td id="organizationListLineDate" class="center">n/a</td> <td id="organizationListLineDate" class="center">n/a</td>
</tr> </tr>
</tbody> </tbody>