diff options
author | Simon Rettberg | 2022-01-12 17:07:42 +0100 |
---|---|---|
committer | Simon Rettberg | 2022-03-09 15:06:54 +0100 |
commit | 1bdf3d4ce66910f07842c7be1043938bccf0a462 (patch) | |
tree | d6a4e1f0185687c224e4a3a901186fe3b0cbd3d9 /modules-available/statistics/api.inc.php | |
parent | api: Don't use mb_strtolower (diff) | |
download | slx-admin-1bdf3d4ce66910f07842c7be1043938bccf0a462.tar.gz slx-admin-1bdf3d4ce66910f07842c7be1043938bccf0a462.tar.xz slx-admin-1bdf3d4ce66910f07842c7be1043938bccf0a462.zip |
[statistics] Make query builder a bit more OOP
Diffstat (limited to 'modules-available/statistics/api.inc.php')
-rw-r--r-- | modules-available/statistics/api.inc.php | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php index 431d4cd4..7aa6de34 100644 --- a/modules-available/statistics/api.inc.php +++ b/modules-available/statistics/api.inc.php @@ -1,26 +1,12 @@ <?php if (Request::any('action') === 'test' && isLocalExecution()) { - $uuid = Request::any('uuid', '', 'string'); - /* - error_log(HardwareInfo::getKclModifications()); - exit; - $x = new HardwareQuery(HardwareInfo::PCI_DEVICE); - //$x->addCompare(false, 'Memory Slot Occupied', '>=', true, 'Memory Slot Count'); - $x->addWhere(true, 'vendor', '=', '8086'); - $x->addGlobalColumn('device'); - $res = $x->query(); - foreach ($res as $row) { - error_log(json_encode($row)); - } - exit; - */ - $data = file_get_contents('/tmp/bla.json'); - Database::exec( - "UPDATE machine SET data = :data WHERE machineuuid = :uuid", - ['uuid' => $uuid, 'data' => $data]); - HardwareParser::parseMachine($uuid, json_decode($data, true)); - echo 'Kweries: ' . Database::getQueryCount(); + $q = new HardwareQuery(HardwareInfo::RAM_MODULE); + $speed = $q->addGlobalColumn('Speed'); + $q->addLocalColumn('Configured Speed')->addCondition('<', $speed); + $speed->addCondition('>', 2666); + $q->addMachineWhere('clientip', '>', 5); + echo $q->buildQuery(), "\n"; exit; } @@ -352,7 +338,7 @@ if ($type[0] === '~') { $hwid = $hwids[$screen['name']]; } else { $hwid = (int)Database::insertIgnore('statistic_hw', 'hwid', - array('hwtype' => DeviceType::SCREEN, 'hwname' => $screen['name'])); + array('hwtype' => HardwareInfo::SCREEN, 'hwname' => $screen['name'])); $hwids[$screen['name']] = $hwid; } // Now add new entries @@ -398,7 +384,7 @@ if ($type[0] === '~') { Database::exec("UPDATE machine_x_hw x, statistic_hw h SET x.disconnecttime = UNIX_TIMESTAMP() WHERE x.machineuuid = :uuid AND x.hwid = h.hwid AND h.hwtype = :type AND x.disconnecttime = 0", - array('uuid' => $uuid, 'type' => DeviceType::SCREEN)); + array('uuid' => $uuid, 'type' => HardwareInfo::SCREEN)); } else { // Some screens connected, make sure old entries get removed Database::exec("UPDATE machine_x_hw x, statistic_hw h @@ -407,7 +393,7 @@ if ($type[0] === '~') { AND x.machineuuid = :uuid", array( 'pairs' => $keepPair, 'uuid' => $uuid, - 'type' => DeviceType::SCREEN, + 'type' => HardwareInfo::SCREEN, )); } } |