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 <thomas.steur@gmail.com>2016-01-12 04:16:24 +0300
committerThomas Steur <thomas.steur@gmail.com>2016-01-12 04:16:24 +0300
commit6eb09249d02cdadd6302d14bcff933febda758df (patch)
tree06696a11a905d250f8b1044741ab6eb61898783a /core/ArchiveProcessor.php
parenta13158499e9cdf737c66c33901dd690285a74561 (diff)
fixes #9357 API response may include more unique visitors than visits
Diffstat (limited to 'core/ArchiveProcessor.php')
-rw-r--r--core/ArchiveProcessor.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/ArchiveProcessor.php b/core/ArchiveProcessor.php
index 0485cc3532..f24b4993b6 100644
--- a/core/ArchiveProcessor.php
+++ b/core/ArchiveProcessor.php
@@ -442,6 +442,16 @@ class ArchiveProcessor
$metrics[] = $uniqueVisitorsMetric;
$uniques = $this->computeNbUniques($metrics);
+
+ // see edge case as described in https://github.com/piwik/piwik/issues/9357 where uniq_visitors might be higher
+ // than visits because we archive / process it after nb_visits. Between archiving nb_visits and nb_uniq_visitors
+ // there could have been a new visit leading to a higher nb_unique_visitors than nb_visits which is not possible
+ // by definition. In this case we simply use the visits metric instead of unique visitors metric.
+ $visits = $row->getColumn('nb_visits');
+ if ($visits !== false && $uniques[$uniqueVisitorsMetric] !== false) {
+ $uniques[$uniqueVisitorsMetric] = min($uniques[$uniqueVisitorsMetric], $visits);
+ }
+
$row->setColumn('nb_uniq_visitors', $uniques[$uniqueVisitorsMetric]);
$row->setColumn('nb_users', $uniques[Metrics::INDEX_NB_USERS]);
}