summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-01-17 17:56:46 +0100
committerSimon Rettberg2020-01-17 17:56:46 +0100
commit701d9b01775a6befa0aafedd1e2d56237ad3ed58 (patch)
tree734fdfd2bd996fa423fa5838d9d835bbbce736e3
parent[statistics_reporting] Remove dead code (diff)
downloadslx-admin-701d9b01775a6befa0aafedd1e2d56237ad3ed58.tar.gz
slx-admin-701d9b01775a6befa0aafedd1e2d56237ad3ed58.tar.xz
slx-admin-701d9b01775a6befa0aafedd1e2d56237ad3ed58.zip
[statistics_reporting] Don't consider machines not recently used
... machine must have been running in the previous 30 days, relative to the "from" timestamp of selected interval.
-rw-r--r--modules-available/statistics_reporting/inc/queries.inc.php15
1 files changed, 9 insertions, 6 deletions
diff --git a/modules-available/statistics_reporting/inc/queries.inc.php b/modules-available/statistics_reporting/inc/queries.inc.php
index 58e9e63b..39e43765 100644
--- a/modules-available/statistics_reporting/inc/queries.inc.php
+++ b/modules-available/statistics_reporting/inc/queries.inc.php
@@ -13,11 +13,12 @@ class Queries
}
}
- public static function getClientStatistics($from, $to, $lowerTimeBound = 0, $upperTimeBound = 24)
+ public static function getClientStatistics(int $from, int $to, $lowerTimeBound = 0, $upperTimeBound = 24)
{
+ $fromCutoff = $from - 86400 * 30;
$res = Database::simpleQuery("SELECT m.machineuuid, m.hostname, m.clientip,
m.locationid, m.firstseen -- , m.lastboot, m.logintime, m.state
- FROM machine m WHERE firstseen <= $to"); // " WHERE lastseen >= :from", compact('from'));
+ FROM machine m WHERE firstseen <= $to AND lastseen > $fromCutoff"); // " WHERE lastseen >= :from", compact('from'));
$machines = self::getStats3($res, $from, $to, $lowerTimeBound, $upperTimeBound);
foreach ($machines as &$machine) {
$machine['medianSessionLength'] = self::calcMedian($machine['sessions']);
@@ -27,11 +28,12 @@ class Queries
return $machines;
}
- public static function getLocationStatistics($from, $to, $lowerTimeBound = 0, $upperTimeBound = 24)
+ public static function getLocationStatistics(int $from, int $to, $lowerTimeBound = 0, $upperTimeBound = 24)
{
+ $fromCutoff = $from - 86400 * 30;
$res = Database::simpleQuery("SELECT m.machineuuid, m.hostname, m.clientip,
m.locationid, m.firstseen -- , m.lastboot, m.logintime, m.state
- FROM machine m WHERE firstseen <= $to"); // " WHERE lastseen >= :from", compact('from'));
+ FROM machine m WHERE firstseen <= $to AND lastseen > $fromCutoff"); // " WHERE lastseen >= :from", compact('from'));
$machines = self::getStats3($res, $from, $to, $lowerTimeBound, $upperTimeBound);
$locations = [];
$keys = ['locationid', 'totalTime', 'totalOffTime', 'totalSessionTime', 'totalStandbyTime', 'totalIdleTime', 'totalIdleTime', 'longSessions', 'shortSessions', 'sessions'];
@@ -58,11 +60,12 @@ class Queries
return $locations;
}
- public static function getOverallStatistics($from, $to, $lowerTimeBound = 0, $upperTimeBound = 24)
+ public static function getOverallStatistics(int $from, int $to, $lowerTimeBound = 0, $upperTimeBound = 24)
{
+ $fromCutoff = $from - 86400 * 30;
$res = Database::simpleQuery("SELECT m.machineuuid, m.hostname, m.clientip,
m.locationid, m.firstseen -- , m.lastboot, m.logintime, m.state
- FROM machine m WHERE firstseen <= $to"); // " WHERE lastseen >= :from", compact('from'));
+ FROM machine m WHERE firstseen <= $to AND lastseen > $fromCutoff"); // " WHERE lastseen >= :from", compact('from'));
$machines = self::getStats3($res, $from, $to, $lowerTimeBound, $upperTimeBound);
$total = false;
$keys = ['totalTime', 'totalOffTime', 'totalSessionTime', 'totalStandbyTime', 'totalIdleTime', 'totalIdleTime', 'longSessions', 'shortSessions', 'sessions'];