diff options
author | Jannik Schönartz | 2018-02-06 13:45:54 +0100 |
---|---|---|
committer | Jannik Schönartz | 2018-02-06 13:45:54 +0100 |
commit | 3d801dcde21c8166e3281a180ef21ff05b175fd6 (patch) | |
tree | f8508e11bc6df5a27f0417ad8098c4ed013a691c /modules-available/statistics/inc/filter.inc.php | |
parent | [usb-lock-off] Reworked config chooser. Switched from the dropdown config sel... (diff) | |
parent | [statistics_reporting] Translation for 'settings' (diff) | |
download | slx-admin-3d801dcde21c8166e3281a180ef21ff05b175fd6.tar.gz slx-admin-3d801dcde21c8166e3281a180ef21ff05b175fd6.tar.xz slx-admin-3d801dcde21c8166e3281a180ef21ff05b175fd6.zip |
Merge branch 'origin/master' into usb-lock-off
Diffstat (limited to 'modules-available/statistics/inc/filter.inc.php')
-rw-r--r-- | modules-available/statistics/inc/filter.inc.php | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/modules-available/statistics/inc/filter.inc.php b/modules-available/statistics/inc/filter.inc.php index be6df752..f6765059 100644 --- a/modules-available/statistics/inc/filter.inc.php +++ b/modules-available/statistics/inc/filter.inc.php @@ -88,15 +88,17 @@ class Filter $lhs = trim(substr($q, 0, $pos)); $rhs = trim(substr($q, $pos + strlen($operator))); - if ($lhs == 'gbram') { + if ($lhs === 'gbram') { $filters[] = new RamGbFilter($operator, $rhs); - } elseif ($lhs == 'state') { + } elseif ($lhs === 'runtime') { + $filters[] = new RuntimeFilter($operator, $rhs); + } elseif ($lhs === 'state') { $filters[] = new StateFilter($operator, $rhs); - } elseif ($lhs == 'hddgb') { + } elseif ($lhs === 'hddgb') { $filters[] = new Id44Filter($operator, $rhs); - } elseif ($lhs == 'location') { + } elseif ($lhs === 'location') { $filters[] = new LocationFilter($operator, $rhs); - } elseif ($lhs == 'subnet') { + } elseif ($lhs === 'subnet') { $filters[] = new SubnetFilter($operator, $rhs); } else { if (array_key_exists($lhs, Page_Statistics::$columns) && Page_Statistics::$columns[$lhs]['column']) { @@ -143,6 +145,38 @@ class RamGbFilter extends Filter } } +class RuntimeFilter extends Filter +{ + public function __construct($operator, $argument) + { + parent::__construct('lastboot', $operator, $argument); + } + + public function whereClause(&$args, &$joins) + { + global $SIZE_RAM; + $upper = time() - (int)$this->argument * 3600; + $lower = $upper - 3600; + $common = "state IN ('OCCUPIED', 'IDLE', 'STANDBY') AND"; + if ($this->operator == '=') { + return "$common ({$this->column} BETWEEN $lower AND $upper)"; + } elseif ($this->operator == '<') { + return "$common {$this->column} > $upper"; + } elseif ($this->operator == '<=') { + return "$common {$this->column} > $lower"; + } elseif ($this->operator == '>') { + return "$common {$this->column} < $lower"; + } elseif ($this->operator == '>=') { + return "$common {$this->column} < $upper"; + } elseif ($this->operator == '!=') { + return "$common ({$this->column} < $lower OR {$this->column} > $upper)"; + } else { + error_log("unimplemented operator in RuntimeFilter: $this->operator"); + return ' 1'; + } + } +} + class Id44Filter extends Filter { public function __construct($operator, $argument) |