Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dependent archive never run #18403

Merged
merged 7 commits into from Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions core/ArchiveProcessor.php
Expand Up @@ -679,8 +679,9 @@ public function processDependentArchive($plugin, $segment)
// vs here we would use
// userId!@%40matomo.org;userId!=hello%40matomo.org;visitorType==new
// thus these would result in different segment hashes and therefore the reports would either show 0 or archive the data twice
$newSegment = Segment::combine($params->getSegment()->getOriginalString(), SegmentExpression::AND_DELIMITER, $segment);
if ($newSegment === $segment && $params->getRequestedPlugin() === $plugin) { // being processed now
$originSegmentString = $params->getSegment()->getOriginalString();
$newSegment = Segment::combine($originSegmentString, SegmentExpression::AND_DELIMITER, $segment);
if (!empty($originSegmentString) && $newSegment === $segment && $params->getRequestedPlugin() === $plugin) { // being processed now
return;
}

Expand Down
10 changes: 8 additions & 2 deletions plugins/Goals/tests/System/ProcessDependentArchiveTest.php
Expand Up @@ -34,6 +34,12 @@ public function tearDown(): void
parent::tearDown();
}

public function test_numArchivesCreated_day()
{
API::getInstance()->getMetrics(self::$fixture->idSite, 'day', '2009-01-04');
$this->assertNumRangeArchives(5, 1); // days;
sgiehl marked this conversation as resolved.
Show resolved Hide resolved
}

public function test_numArchivesCreated()
{
API::getInstance()->get(self::$fixture->idSite, 'range', $this->requestRange);
Expand All @@ -46,9 +52,9 @@ public function test_numArchivesCreatedWithSegment()
$this->assertNumRangeArchives(6);
}

private function assertNumRangeArchives($expectedArchives)
private function assertNumRangeArchives($expectedArchives,$period = 5)
{
$archives = Db::fetchAll('SELECT `name` from ' . Common::prefixTable($this->archiveTable) . ' WHERE period = 5 and `name` like "done%"');
$archives = Db::fetchAll('SELECT `name` from ' . Common::prefixTable($this->archiveTable) . ' WHERE period = '.$period.' and `name` like "done%"');
$numArchives = count($archives);
$message = sprintf('Expected archives: %s, got: %s. These were the archives %s', $expectedArchives, $numArchives, json_encode($archives));
$this->assertEquals($expectedArchives, $numArchives, $message);
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPUnit/Integration/ArchiveTest.php
Expand Up @@ -237,7 +237,7 @@ public function test_archivingInvalidRange_doesNotReprocessInvalidDay()
$expected = [
['idarchive' => '2', 'date1' => '2020-03-04', 'date2' => '2020-03-04', 'name' => 'done', 'value' => '1'],
['idarchive' => '13', 'date1' => '2020-03-05', 'date2' => '2020-03-05', 'name' => 'done', 'value' => '1'],
['idarchive' => '16', 'date1' => '2020-03-04', 'date2' => '2020-03-05', 'name' => 'done.VisitsSummary', 'value' => '1'],
['idarchive' => '18', 'date1' => '2020-03-04', 'date2' => '2020-03-05', 'name' => 'done.VisitsSummary', 'value' => '1'],
];
$this->assertEquals($expected, $archives);
}
Expand Down