From b8e32e237af996a598207fec6ca2268628d91d69 Mon Sep 17 00:00:00 2001 From: Christian Hofmaier Date: Tue, 6 Dec 2016 15:56:04 +0100 Subject: [statistics_reporting] Added time bounds and time cutoff possibility. --- .../statistics_reporting/page.inc.php | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'modules-available/statistics_reporting/page.inc.php') diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php index aaf191df..e009317c 100644 --- a/modules-available/statistics_reporting/page.inc.php +++ b/modules-available/statistics_reporting/page.inc.php @@ -3,6 +3,9 @@ class Page_Statistics_Reporting extends Page { + private $cutOffTimer; + + /** * Called before any page rendering happens - early hook to check parameters etc. */ @@ -21,25 +24,24 @@ class Page_Statistics_Reporting extends Page */ protected function doRender() { - // TODO: got empty machine with alot of logins. isn't shown in the inner-join hostname query below. - // $res = Database::simpleQuery("SELECT machineuuid as 'hostname', COUNT(*) AS 'count' FROM statistic WHERE typeid='~session-length' GROUP BY machineuuid ORDER BY 2 DESC"); - - // TODO: session-length liefert 3000 Einträge mehr als vmchooser-session? (logins ohne ausgewählter VM -> Session endet trotzdem mit session-length Meldung) - - // TODO change AVG to median + // timespan you want to see = Days selected * seconds per Day + // default = 14 days + $cutOff = Request::get('cutoff', 14, 'int'); + $chooserData = array('cutoff' => $cutOff); + $this->cutOffTimer = $cutOff * 86400; // total time online, average time online, total number of logins - $res = StatisticReporting::getOverallStatistics(); + $res = StatisticReporting::getOverallStatistics($this->cutOffTimer); $row = $res->fetch(PDO::FETCH_NUM); $data = array('time' => StatisticReporting::formatSeconds($row[0]), 'avgTime' => StatisticReporting::formatSeconds($row[1]), 'totalLogins' => $row[2]); //total time offline - $res = StatisticReporting::getTotalOffline(); + $res = StatisticReporting::getTotalOfflineStatistics($this->cutOffTimer); $row = $res->fetch(PDO::FETCH_NUM); $data = array_merge($data, array('totalOfftime' => StatisticReporting::formatSeconds($row[0]))); // per location - $res = StatisticReporting::getLocationStatistics(); + $res = StatisticReporting::getLocationStatistics($this->cutOffTimer); $data[] = array('perLocation' => array()); while ($row = $res->fetch(PDO::FETCH_NUM)) { $data['perLocation'][] = array('location' => $row[0], 'time' => StatisticReporting::formatSeconds($row[1]), 'timeInSeconds' => $row[1], @@ -47,7 +49,7 @@ class Page_Statistics_Reporting extends Page } // per client - $res = StatisticReporting::getClientStatistics(); + $res = StatisticReporting::getClientStatistics($this->cutOffTimer); $data[] = array('perClient' => array()); while ($row = $res->fetch(PDO::FETCH_NUM)) { $data['perClient'][] = array('hostname' => $row[0], 'time' => StatisticReporting::formatSeconds($row[1]), 'timeInSeconds' => $row[1], @@ -56,21 +58,20 @@ class Page_Statistics_Reporting extends Page } // per user - $res = StatisticReporting::getUserStatistics(); + $res = StatisticReporting::getUserStatistics($this->cutOffTimer); $data[] = array('perUser' => array()); while ($row = $res->fetch(PDO::FETCH_NUM)) { $data['perUser'][] = array('user' => $row[0], 'loginCount' => $row[1]); } // per vm - $res = StatisticReporting::getVMStatistics(); + $res = StatisticReporting::getVMStatistics($this->cutOffTimer); $data[] = array('perVM' => array()); while ($row = $res->fetch(PDO::FETCH_NUM)) { $data['perVM'][] = array('vm' => $row[0], 'loginCount' => $row[1]); } - - Render::addTemplate('columnChooser'); + Render::addTemplate('columnChooser', $chooserData); Render::addTemplate('_page', $data); } } -- cgit v1.2.3-55-g7522