mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-15 22:51:37 -07:00
partially merge of https://github.com/jokob-sk/Pi.Alert/commit/86ffe8ba36a9792a1cf742dc50fe23ad9f8ae848
This commit is contained in:
@@ -450,37 +450,20 @@ function PiaToggleArpScan() {
|
|||||||
function getDevicesTotals() {
|
function getDevicesTotals() {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
// All
|
// combined query
|
||||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('all'));
|
$result = $db->query(
|
||||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
'SELECT
|
||||||
$devices = $row[0];
|
(SELECT COUNT(*) FROM Devices '. getDeviceCondition ('all').') as devices,
|
||||||
|
(SELECT COUNT(*) FROM Devices '. getDeviceCondition ('connected').') as connected,
|
||||||
// On-Line
|
(SELECT COUNT(*) FROM Devices '. getDeviceCondition ('favorites').') as favorites,
|
||||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('connected') );
|
(SELECT COUNT(*) FROM Devices '. getDeviceCondition ('new').') as new,
|
||||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
(SELECT COUNT(*) FROM Devices '. getDeviceCondition ('down').') as down,
|
||||||
$connected = $row[0];
|
(SELECT COUNT(*) FROM Devices '. getDeviceCondition ('archived').') as archived
|
||||||
|
');
|
||||||
// Favorites
|
|
||||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('favorites') );
|
|
||||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
|
||||||
$favorites = $row[0];
|
|
||||||
|
|
||||||
// New
|
|
||||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('new') );
|
|
||||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
|
||||||
$newDevices = $row[0];
|
|
||||||
|
|
||||||
// Down Alerts
|
|
||||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('down'));
|
|
||||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
|
||||||
$downAlert = $row[0];
|
|
||||||
|
|
||||||
// Archived
|
$row = $result -> fetchArray (SQLITE3_NUM);
|
||||||
$result = $db->query('SELECT COUNT(*) FROM Devices '. getDeviceCondition ('archived'));
|
|
||||||
$row = $result -> fetchArray (SQLITE3_NUM);
|
|
||||||
$archived = $row[0];
|
|
||||||
|
|
||||||
echo (json_encode (array ($devices, $connected, $favorites, $newDevices, $downAlert, $archived)));
|
echo (json_encode (array ($row[0], $row[1], $row[2], $row[3], $row[4], $row[5])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user