Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2019-05-19 19:53:02 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2019-05-19 19:53:02 +0300
commit17ca84d486ee44662e42d10f8c3d18d7ab6d3bbc (patch)
tree77a242b3f56f2e1f8a9707b181c76db21d7b01d1 /plugins/Insights
parent1f3aaa588f7b755c195fa019d369d5b982b4cc78 (diff)
Make sure to ignore filter limit in insights when "all" is selected (#14356)
* Make sure to ignore filter limit when all selected * only remove if not unlimited filter is selected * add test
Diffstat (limited to 'plugins/Insights')
-rw-r--r--plugins/Insights/DataTable/Filter/Limit.php6
-rw-r--r--plugins/Insights/Visualizations/Insight.php9
-rw-r--r--plugins/Insights/tests/Unit/FilterLimitTest.php14
3 files changed, 26 insertions, 3 deletions
diff --git a/plugins/Insights/DataTable/Filter/Limit.php b/plugins/Insights/DataTable/Filter/Limit.php
index 42f6440f10..afcff5b666 100644
--- a/plugins/Insights/DataTable/Filter/Limit.php
+++ b/plugins/Insights/DataTable/Filter/Limit.php
@@ -37,18 +37,18 @@ class Limit extends BaseFilter
$countIncreaser++;
- if ($countIncreaser > $this->limitPositive) {
+ if ($countIncreaser > $this->limitPositive && $this->limitPositive > -1) {
$table->deleteRow($key);
}
} else {
$countDecreaser++;
- if ($countDecreaser > $this->limitNegative) {
+ if ($countDecreaser > $this->limitNegative && $this->limitNegative > -1) {
$table->deleteRow($key);
}
}
}
}
-} \ No newline at end of file
+}
diff --git a/plugins/Insights/Visualizations/Insight.php b/plugins/Insights/Visualizations/Insight.php
index a6ec4a9865..21d5ed476e 100644
--- a/plugins/Insights/Visualizations/Insight.php
+++ b/plugins/Insights/Visualizations/Insight.php
@@ -64,6 +64,10 @@ class Insight extends Visualization
$filterLimit = $this->requestConfig->filter_limit;
$limitIncrease = 0;
+ if ($filterLimit == -1) {
+ return -1;
+ }
+
if ($this->requestConfig->limit_increaser && !$this->requestConfig->limit_decreaser) {
$limitIncrease = $filterLimit;
} elseif ($this->requestConfig->limit_increaser && $this->requestConfig->limit_decreaser) {
@@ -76,6 +80,11 @@ class Insight extends Visualization
private function getLimitDecrease()
{
$filterLimit = $this->requestConfig->filter_limit;
+
+ if ($filterLimit == -1) {
+ return -1;
+ }
+
$limitDecrease = $filterLimit - $this->getLimitIncrease();
return abs($limitDecrease);
diff --git a/plugins/Insights/tests/Unit/FilterLimitTest.php b/plugins/Insights/tests/Unit/FilterLimitTest.php
index 6f6d703b0a..d7e38575e4 100644
--- a/plugins/Insights/tests/Unit/FilterLimitTest.php
+++ b/plugins/Insights/tests/Unit/FilterLimitTest.php
@@ -72,6 +72,20 @@ class FilterLimitTest extends BaseUnitTest
$this->assertOrder(array('pos1', 'pos2', 'neg1', 'pos3', 'neg2', 'neg3', 'pos4', 'pos5', 'neg4', 'neg5'));
}
+ public function testShouldReturnAllRowsIfNoLimitIsSet()
+ {
+ $this->applyLimit($limitIncreaser = -1, $limitDecreaser = -1);
+
+ $this->assertOrder(array('pos1', 'pos2', 'neg1', 'pos3', 'neg2', 'neg3', 'pos4', 'pos5', 'neg4', 'neg5'));
+ }
+
+ public function testShouldReturnAllRowsIfNoLimitIsSetOnlyIncreaser()
+ {
+ $this->applyLimit($limitIncreaser = -1, $limitDecreaser = 2);
+
+ $this->assertOrder(array('pos1', 'pos2', 'neg1', 'pos3', 'neg2', 'pos4', 'pos5'));
+ }
+
private function applyLimit($limitIncrease, $limitDecrease)
{
$filter = new Limit($this->table, 'growth', $limitIncrease, $limitDecrease);