From d42a3b1f1d30d54f89ff4830163b00364f775e83 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 21 Jan 2019 12:19:35 +0100 Subject: [statistics] Improve ID44 filter matching --- modules-available/statistics/inc/filter.inc.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/modules-available/statistics/inc/filter.inc.php b/modules-available/statistics/inc/filter.inc.php index 565ea5f0..3ccea2c3 100644 --- a/modules-available/statistics/inc/filter.inc.php +++ b/modules-available/statistics/inc/filter.inc.php @@ -187,20 +187,24 @@ class Id44Filter extends Filter public function whereClause(&$args, &$joins) { global $SIZE_ID44; - $lower = floor(Page_Statistics::findBestValue($SIZE_ID44, $this->argument, false) * 1024 - 100); - $upper = ceil(Page_Statistics::findBestValue($SIZE_ID44, $this->argument, true) * 1024 + 100); + if ($this->operator === '=' || $this->operator === '!=') { + $lower = floor(Page_Statistics::findBestValue($SIZE_ID44, $this->argument, false) * 1024 - 100); + $upper = ceil(Page_Statistics::findBestValue($SIZE_ID44, $this->argument, true) * 1024 + 100); + } else { + $lower = $upper = round($this->argument * 1024); + } - if ($this->operator == '=') { + if ($this->operator === '=') { return " id44mb BETWEEN $lower AND $upper"; - } elseif ($this->operator == '!=') { + } elseif ($this->operator === '!=') { return " id44mb < $lower OR id44mb > $upper"; - } elseif ($this->operator == '<=') { - return " id44mb < $upper"; - } elseif ($this->operator == '>=') { - return " id44mb > $lower"; - } elseif ($this->operator == '<') { + } elseif ($this->operator === '<=') { + return " id44mb <= $upper"; + } elseif ($this->operator === '>=') { + return " id44mb >= $lower"; + } elseif ($this->operator === '<') { return " id44mb < $lower"; - } elseif ($this->operator == '>') { + } elseif ($this->operator === '>') { return " id44mb > $upper"; } else { error_log("unimplemented operator in Id44Filter: $this->operator"); -- cgit v1.2.3-55-g7522