From e90884555e1a339d07958691c44b89a48f8d4833 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 13 Dec 2019 17:36:51 +0100 Subject: [statistics] Fix date range queries to match by day, not by second --- modules-available/statistics/inc/statisticsfilter.inc.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'modules-available') diff --git a/modules-available/statistics/inc/statisticsfilter.inc.php b/modules-available/statistics/inc/statisticsfilter.inc.php index 934e01da..c5d2f0f2 100644 --- a/modules-available/statistics/inc/statisticsfilter.inc.php +++ b/modules-available/statistics/inc/statisticsfilter.inc.php @@ -55,12 +55,22 @@ class StatisticsFilter /* returns a where clause and adds needed operators to the passed array */ public function whereClause(&$args, &$joins) { - $key = StatisticsFilter::getNewKey($this->column); + $key = self::getNewKey($this->column); $addendum = ''; /* check if we have to do some parsing*/ if (self::$columns[$this->column]['type'] === 'date') { $args[$key] = strtotime($this->argument); + if ($this->operator === '=' || $this->operator === '!=') { + $key2 = self::getNewKey($this->column); + $args[$key2] = strtotime(' +1 day', $args[$key]); + return ($this->operator === '=' ? '' : 'NOT ') . 'm.' . $this->column . " BETWEEN :$key AND :$key2"; + } + if ($this->operator === '>') { + $args[$key] = strtotime('+1 day', $args[$key]); + } elseif ($this->operator === '<') { + $args[$key] = strtotime('-1 day', $args[$key]); + } } else { $args[$key] = $this->argument; if ($this->operator === '~' || $this->operator === '!~') { -- cgit v1.2.3-55-g7522