diff options
author | Simon Rettberg | 2022-04-28 16:56:31 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-04-28 16:56:31 +0200 |
commit | b506fb2dbc87a187159e3d576672d384a42d8972 (patch) | |
tree | 4dc20fabe5c9827704a3f400e1058a1a3bcb01fc /modules-available/statistics/inc | |
parent | [passthrough] Link to statistics search from vendor/device (diff) | |
download | slx-admin-b506fb2dbc87a187159e3d576672d384a42d8972.tar.gz slx-admin-b506fb2dbc87a187159e3d576672d384a42d8972.tar.xz slx-admin-b506fb2dbc87a187159e3d576672d384a42d8972.zip |
[statistics] ID45_live: Filter 0 if not explicitly matching for it
0 means the machine doesn't have an ID45 partition. Most likely, when
you do something like "< 10000" you want to find machines which are low
on ID45 space, but not those that don't even have any. So implicitly add
"live_id45 != 0" if the user didn't explicitly query for "= 0".
Diffstat (limited to 'modules-available/statistics/inc')
-rw-r--r-- | modules-available/statistics/inc/statisticsfilter.inc.php | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/modules-available/statistics/inc/statisticsfilter.inc.php b/modules-available/statistics/inc/statisticsfilter.inc.php index 59c5e833..f33c423f 100644 --- a/modules-available/statistics/inc/statisticsfilter.inc.php +++ b/modules-available/statistics/inc/statisticsfilter.inc.php @@ -271,7 +271,7 @@ abstract class StatisticsFilter 'live_swapfree' => new SimpleStatisticsFilter('live_swapfree', self::OP_ORDINAL, 'MiB'), 'live_memfree' => new SimpleStatisticsFilter('live_memfree', self::OP_ORDINAL, 'MiB'), 'live_tmpfree' => new SimpleStatisticsFilter('live_tmpfree', self::OP_ORDINAL, 'MiB'), - 'live_id45free' => new SimpleStatisticsFilter('live_id45free', self::OP_ORDINAL, 'MiB'), + 'live_id45free' => new SimpleNotZeroStatisticsFilter('live_id45free', self::OP_ORDINAL, 'MiB'), 'standbycrash' => new StandbyCrashStatisticsFilter(), 'pcidev' => new PciDeviceStatisticsFilter(), 'anydev' => new AnyHardwarePropStatisticsFilter(), @@ -316,6 +316,20 @@ class SimpleStatisticsFilter extends StatisticsFilter } +class SimpleNotZeroStatisticsFilter extends SimpleStatisticsFilter +{ + + public function whereClause(string $operator, $argument, array &$args, array &$joins): string + { + $str = parent::whereClause($operator, $argument, $args, $joins); + if ((int)$argument !== 0 || $operator !== '=') { + $str = "($str AND {$this->column} != 0)"; + } + return $str; + } + +} + class EnumStatisticsFilter extends SimpleStatisticsFilter { |