From 23d8c6fc0c3b031aa081ee1a245f9b0792514fd3 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 28 Nov 2017 16:41:33 +0100 Subject: [statistics] Introduce state column to get rid of complicated state determination This also adds support for the STANDBY state --- modules-available/rebootcontrol/inc/rebootqueries.inc.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'modules-available/rebootcontrol/inc') diff --git a/modules-available/rebootcontrol/inc/rebootqueries.inc.php b/modules-available/rebootcontrol/inc/rebootqueries.inc.php index 8f65b756..1bdcb9a2 100644 --- a/modules-available/rebootcontrol/inc/rebootqueries.inc.php +++ b/modules-available/rebootcontrol/inc/rebootqueries.inc.php @@ -21,7 +21,7 @@ class RebootQueries } $res = Database::simpleQuery(" SELECT machine.machineuuid, machine.hostname, machine.clientip, - machine.lastboot, machine.lastseen, machine.logintime, + machine.lastboot, machine.lastseen, machine.logintime, machine.state, $sessionField, machine.currentuser, machine.locationid FROM machine $leftJoin @@ -29,12 +29,12 @@ class RebootQueries $ret = $res->fetchAll(PDO::FETCH_ASSOC); $NOW = time(); foreach ($ret as &$row) { - if ($row['lastboot'] == 0 || $NOW - $row['lastseen'] > 600) { - $row['status'] = 0; - } else { + if ($row['state'] === 'IDLE' || $row['state'] === 'OCCUPIED') { $row['status'] = 1; + } else { + $row['status'] = 0; } - if ($row['status'] === 0 || $row['logintime'] == 0) { + if ($row['state'] !== 'OCCUPIED') { $row['currentuser'] = ''; $row['currentsession'] = ''; } -- cgit v1.2.3-55-g7522