diff options
author | Simon Rettberg | 2022-12-08 16:21:45 +0100 |
---|---|---|
committer | Simon Rettberg | 2022-12-08 16:21:45 +0100 |
commit | f3830941e4a446b96ceaa6744c70bbf7be614bda (patch) | |
tree | de2a964cf4e8c98fa6161748dcb52cfc991559f1 /modules-available/statistics/inc | |
parent | [remoteaccess] Add list of active locations to overview page (diff) | |
download | slx-admin-f3830941e4a446b96ceaa6744c70bbf7be614bda.tar.gz slx-admin-f3830941e4a446b96ceaa6744c70bbf7be614bda.tar.xz slx-admin-f3830941e4a446b96ceaa6744c70bbf7be614bda.zip |
[statistics] Only show graph if no non-location filters are set
Closes #3694
Diffstat (limited to 'modules-available/statistics/inc')
-rw-r--r-- | modules-available/statistics/inc/statisticsfilter.inc.php | 5 | ||||
-rw-r--r-- | modules-available/statistics/inc/statisticsfilterset.inc.php | 27 |
2 files changed, 32 insertions, 0 deletions
diff --git a/modules-available/statistics/inc/statisticsfilter.inc.php b/modules-available/statistics/inc/statisticsfilter.inc.php index f90c15c7..0b364715 100644 --- a/modules-available/statistics/inc/statisticsfilter.inc.php +++ b/modules-available/statistics/inc/statisticsfilter.inc.php @@ -808,6 +808,11 @@ class DatabaseFilter return get_class($this->inst) === $what; } + public function getClass(): string + { + return get_class($this->inst); + } + } StatisticsFilter::initConstants(); diff --git a/modules-available/statistics/inc/statisticsfilterset.inc.php b/modules-available/statistics/inc/statisticsfilterset.inc.php index 90a39f7d..c1401c11 100644 --- a/modules-available/statistics/inc/statisticsfilterset.inc.php +++ b/modules-available/statistics/inc/statisticsfilterset.inc.php @@ -107,4 +107,31 @@ class StatisticsFilterSet return false; } + public function suitableForUsageGraph(): bool + { + foreach ($this->filters as $filter) { + switch ($filter->getClass()) { + case 'LocationStatisticsFilter': + case 'IsClientStatisticsFilter': + break; + case 'DateStatisticsFilter': + if ($filter->op !== '>' && $filter->op !== '>=') + return false; + if (strtotime($filter->argument) + 3*86400 > time()) + return false; + break; + case 'RuntimeStatisticsFilter': + if ($filter->op !== '>' && $filter->op !== '>=') + return false; + if ($filter->argument < 3 * 24) + return false; + break; + default: + error_log('NOPE: ' . $filter->getClass()); + return false; + } + } + return true; + } + } |