Added duration column in stat visitors.
This commit is contained in:
parent
c8e4dcad0c
commit
8e38a03eb0
4 changed files with 61 additions and 4 deletions
|
@ -453,7 +453,9 @@ public class StatoolInfos
|
|||
|
||||
for (VisitorStat stat : stator.getVisitorStats().sortByVisitCount().reverse())
|
||||
{
|
||||
System.out.println(String.format("%d %d %s %s", stat.getVisits().size(), stat.getLogCount(), stat.getIp(), stat.getUserAgent()));
|
||||
System.out.println(
|
||||
String.format("%d %d %d %s %s %s", stat.getVisits().size(), stat.getLogCount(), stat.getVisits().getDurationSum().toSeconds(), Chrono.format(stat.getVisits().getDurationSum()),
|
||||
stat.getIp(), stat.getUserAgent()));
|
||||
}
|
||||
|
||||
System.err.println(String.format("%s %10d", "Visitor count: ", stator.getVisitorStats().size()));
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package fr.devinsy.statoolinfos.metrics.http;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.YearMonth;
|
||||
|
@ -72,6 +73,21 @@ public class Visit
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the duration.
|
||||
*
|
||||
* @return the duration
|
||||
*/
|
||||
public Duration getDuration()
|
||||
{
|
||||
Duration result;
|
||||
|
||||
result = Duration.between(this.start, this.end);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
public LocalDateTime getEnd()
|
||||
{
|
||||
return this.end;
|
||||
|
@ -241,5 +257,4 @@ public class Visit
|
|||
{
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package fr.devinsy.statoolinfos.metrics.http;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.YearMonth;
|
||||
|
@ -204,4 +205,23 @@ public class Visits extends ArrayList<Visit>
|
|||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the duration sum.
|
||||
*
|
||||
* @return the duration sum
|
||||
*/
|
||||
public Duration getDurationSum()
|
||||
{
|
||||
Duration result;
|
||||
|
||||
result = Duration.ofSeconds(0);
|
||||
for (Visit visit : this)
|
||||
{
|
||||
result = result.plus(visit.getDuration());
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,8 +94,7 @@ public class Chrono
|
|||
{
|
||||
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);
|
||||
result = format(duration);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -153,4 +152,25 @@ public class Chrono
|
|||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format.
|
||||
*
|
||||
* @param duration
|
||||
* the duration
|
||||
* @return the string
|
||||
*/
|
||||
public static String format(final Duration duration)
|
||||
{
|
||||
String result;
|
||||
|
||||
long seconds = duration.toSecondsPart();
|
||||
long minutes = duration.toMinutesPart();
|
||||
long hours = duration.toHoursPart();
|
||||
|
||||
result = String.format("%02d:%02d:%02d", hours, minutes, seconds);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue