From 9e91718bb5a74cde2d6f95ff01c831eba30d6475 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 6 Nov 2019 15:40:53 +0100 Subject: [locations] Show number of machines with configvar overrides --- modules-available/locations/pages/locations.inc.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'modules-available/locations/pages') diff --git a/modules-available/locations/pages/locations.inc.php b/modules-available/locations/pages/locations.inc.php index b1fd77d4..a8cd2e63 100644 --- a/modules-available/locations/pages/locations.inc.php +++ b/modules-available/locations/pages/locations.inc.php @@ -91,6 +91,7 @@ class SubPage // Statistics: Count machines for each subnet $unassigned = false; $unassignedLoad = 0; + $unassignedOverrides = 0; $allowedLocationIds = User::getAllowedLocations("location.view"); foreach (array_keys($locationList) as $lid) { @@ -118,8 +119,8 @@ class SubPage if (in_array(0, $allowedLocationIds)) { $extra = ' OR locationid IS NULL'; } - $res = Database::simpleQuery("SELECT locationid, Count(*) AS cnt, Sum(If(state = 'OCCUPIED', 1, 0)) AS used - FROM machine WHERE (locationid IN (:allowedLocationIds) $extra) GROUP BY locationid", compact('allowedLocationIds')); + $res = Database::simpleQuery("SELECT m.locationid, Count(*) AS cnt, Sum(If(m.state = 'OCCUPIED', 1, 0)) AS used + FROM machine m WHERE (locationid IN (:allowedLocationIds) $extra) GROUP BY locationid", compact('allowedLocationIds')); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { $locId = (int)$row['locationid']; if (isset($locationList[$locId])) { @@ -130,6 +131,16 @@ class SubPage $unassignedLoad += $row['used']; } } + $res = Database::simpleQuery("SELECT m.locationid, Count(DISTINCT sm.machineuuid) AS cnt FROM setting_machine sm + INNER JOIN machine m USING (machineuuid) GROUP BY m.locationid"); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $locId = (int)$row['locationid']; + if (isset($locationList[$locId])) { + $locationList[$locId]['machineVarsOverrideCount'] = $row['cnt']; + } else { + $unassignedOverrides += $row['cnt']; + } + } unset($loc); foreach ($locationList as &$loc) { if (!in_array($loc['locationid'], $allowedLocationIds)) @@ -150,6 +161,7 @@ class SubPage } } unset($loc); + } // Show currently active sysconfig for each location $defaultConfig = false; @@ -222,6 +234,7 @@ class SubPage 'mismatchMachines' => $mismatchMachines, 'unassignedCount' => $unassigned, 'unassignedLoad' => ($unassigned ? (round(($unassignedLoad / $unassigned) * 100) . ' %') : ''), + 'unassignedOverrides' => $unassignedOverrides, 'defaultConfig' => $defaultConfig, 'addAllowedList' => array_values($addAllowedList), ); -- cgit v1.2.3-55-g7522