diff options
author | dizzy <diosmosis@users.noreply.github.com> | 2021-02-05 01:22:11 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-05 01:22:11 +0300 |
commit | 490dc3a1a09e4263b4893cbbbf600ba505d9add4 (patch) | |
tree | 2fca42614fec12907ecac1ae217e1305baa4144a | |
parent | bc53bc36ebebfe50d83d6ce381aa8bb6cd2cb15c (diff) |
Refactor segment re-archiving in past behavior to be on demand (#17005)
* Invalidate past archives on demand when adding/updating segments, rather than trying to check when running core:archive
* start on rewriting test
* rewrite SegmentArchivingTest and get to pass
* get sites as superuser
* add update to rearchive segments if they were created/update between last archive time and update time
* remove unused parameter
* fix build
* fix tests
* sanity check
* fix bug, we should not forget archives to invalidate unless all related archives are being invalidated
* fix tests and make fix more complete
* fix test
* update counts in test
* fix test for last time hopefully
* fix another test
* remove debugging code
17 files changed, 644 insertions, 500 deletions
diff --git a/core/Archive/ArchiveInvalidator.php b/core/Archive/ArchiveInvalidator.php index 2301c3ed97..f0aa119385 100644 --- a/core/Archive/ArchiveInvalidator.php +++ b/core/Archive/ArchiveInvalidator.php @@ -12,6 +12,7 @@ namespace Piwik\Archive; use Piwik\Archive\ArchiveInvalidator\InvalidationResult; use Piwik\ArchiveProcessor\ArchivingStatus; use Piwik\ArchiveProcessor\Loader; +use Piwik\ArchiveProcessor\Rules; use Piwik\Config; use Piwik\Container\StaticContainer; use Piwik\CronArchive\ReArchiveList; @@ -332,7 +333,11 @@ class ArchiveInvalidator Loader::invalidateMinVisitTimeCache($idSite); } - if ($period != 'range') { + $isInvalidatingDays = $period == 'day' || $cascadeDown || empty($period); + $isNotInvalidatingSegment = empty($segment) || empty($segment->getString()); + if ($isInvalidatingDays + && $isNotInvalidatingSegment + ) { foreach ($idSites as $idSite) { foreach ($dates as $date) { if (is_string($date)) { @@ -468,7 +473,7 @@ class ArchiveInvalidator * @throws \Exception * @api */ - public function reArchiveReport($idSites, string $plugin, string $report = null, Date $startDate = null) + public function reArchiveReport($idSites, string $plugin = null, string $report = null, Date $startDate = null, Segment $segment = null) { $date2 = Date::yesterday(); @@ -500,23 +505,13 @@ class ArchiveInvalidator $name .= '.' . $report; } - $this->markArchivesAsInvalidated($idSites, $dates, 'day', null, $cascadeDown = false, $forceInvalidateRanges = false, $name); - foreach ($idSites as $idSite) { - $segmentDatesToInvalidate = $this->getSegmentArchiving()->getSegmentArchivesToInvalidate($idSite); - foreach ($segmentDatesToInvalidate as $info) { - $latestDate = Date::factory($info['date']); - $latestDate = $latestDate->isEarlier($startDate) ? $startDate : $latestDate; - - $datesToInvalidateForSegment = []; - - $date = $latestDate; - while ($date->isEarlier($date2)) { - $datesToInvalidateForSegment[] = $date; - $date = $date->addDay(1); + $this->markArchivesAsInvalidated($idSites, $dates, 'day', $segment, $cascadeDown = false, $forceInvalidateRanges = false, $name); + if (empty($segment)) { + foreach ($idSites as $idSite) { + foreach (Rules::getSegmentsToProcess([$idSite]) as $segment) { + $this->markArchivesAsInvalidated($idSites, $dates, 'day', new Segment($segment, [$idSite]), + $cascadeDown = false, $forceInvalidateRanges = false, $name); } - - $this->markArchivesAsInvalidated($idSites, $datesToInvalidateForSegment, 'day', new Segment($info['segment'], [$idSite]), - $cascadeDown = false, $forceInvalidateRanges = false, $name); } } } @@ -548,7 +543,8 @@ class ArchiveInvalidator * @param string|null $report * @param Date|null $startDate */ - public function scheduleReArchiving($idSites, string $pluginName, $report = null, Date $startDate = null) + public function scheduleReArchiving($idSites, string $pluginName = null, $report = null, Date $startDate = null, + Segment $segment = null) { if (!empty($report)) { $this->removeInvalidationsSafely($idSites, $pluginName, $report); @@ -560,6 +556,7 @@ class ArchiveInvalidator 'pluginName' => $pluginName, 'report' => $report, 'startDate' => $startDate ? $startDate->getTimestamp() : null, + 'segment' => $segment ? $segment->getString() : null, ])); } catch (\Throwable $ex) { $this->logger->info("Failed to schedule rearchiving of past reports for $pluginName plugin."); @@ -581,11 +578,13 @@ class ArchiveInvalidator continue; } + $idSites = Site::getIdSitesFromIdSitesString($entry['idSites']); $this->reArchiveReport( $entry['idSites'], $entry['pluginName'], $entry['report'], - !empty($entry['startDate']) ? Date::factory((int) $entry['startDate']) : null + !empty($entry['startDate']) ? Date::factory((int) $entry['startDate']) : null, + !empty($entry['segment']) ? new Segment($entry['segment'], $idSites) : null ); } catch (\Throwable $ex) { $this->logger->info("Failed to create invalidations for report re-archiving (idSites = {idSites}, pluginName = {pluginName}, report = {report}, startDate = {startDateTs}): {ex}", [ diff --git a/core/CronArchive.php b/core/CronArchive.php index 067b85e6db..8d634000ba 100644 --- a/core/CronArchive.php +++ b/core/CronArchive.php @@ -199,8 +199,6 @@ class CronArchive */ private $periodIdsToLabels; - private $processNewSegmentsFrom; - /** * @var ArchiveFilter */ @@ -219,17 +217,13 @@ class CronArchive /** * Constructor. * - * @param string|null $processNewSegmentsFrom When to archive new segments from. See [General] process_new_segments_from - * for possible values. * @param LoggerInterface|null $logger */ - public function __construct($processNewSegmentsFrom = null, LoggerInterface $logger = null) + public function __construct(LoggerInterface $logger = null) { $this->logger = $logger ?: StaticContainer::get('Psr\Log\LoggerInterface'); $this->formatter = new Formatter(); - $this->processNewSegmentsFrom = $processNewSegmentsFrom ?: StaticContainer::get('ini.General.process_new_segments_from'); - $this->invalidator = StaticContainer::get('Piwik\Archive\ArchiveInvalidator'); $this->isArchiveProfilingEnabled = Config::getInstance()->Debug['archiving_profile'] == 1; @@ -276,7 +270,7 @@ class CronArchive public function init() { - $this->segmentArchiving = new SegmentArchiving($this->processNewSegmentsFrom, $this->dateLastForced); + $this->segmentArchiving = StaticContainer::get(SegmentArchiving::class); /** * This event is triggered during initializing archiving. @@ -567,7 +561,7 @@ class CronArchive $visits = (int) $visits; $this->logger->info("Archived website id {$params['idSite']}, period = {$params['period']}, date = " - . "{$params['date']}, segment = '" . (isset($params['segment']) ? urldecode($params['segment']) : '') . "', " + . "{$params['date']}, segment = '" . (isset($params['segment']) ? urldecode(urldecode($params['segment'])) : '') . "', " . ($plugin ? "plugin = $plugin, " : "") . ($report ? "report = $report, " : "") . "$visits visits found. $timer"); } @@ -778,7 +772,7 @@ class CronArchive { if (empty($this->segmentArchiving)) { // might not be initialised if init is not called - $this->segmentArchiving = new SegmentArchiving($this->processNewSegmentsFrom, $this->dateLastForced); + $this->segmentArchiving = StaticContainer::get(SegmentArchiving::class); } $this->logger->debug("Checking for queued invalidations..."); @@ -838,26 +832,6 @@ class CronArchive $this->invalidateWithSegments($idSiteToInvalidate, $date, 'range', $_forceInvalidateNonexistant = true); } - // for new segments, invalidate past dates - $segmentDatesToInvalidate = $this->segmentArchiving->getSegmentArchivesToInvalidateForNewSegments($idSiteToInvalidate); - - foreach ($segmentDatesToInvalidate as $info) { - $this->logger->info(' Segment "{segment}" was created or changed recently and will therefore archive today (for site ID = {idSite})', [ - 'segment' => $info['segment'], - 'idSite' => $idSiteToInvalidate, - ]); - - $earliestDate = $info['date']; - - $allDates = PeriodFactory::build('range', $earliestDate . ',today')->getSubperiods(); - $allDates = array_map(function (Period $p) { - return $p->getDateStart()->toString(); - }, $allDates); - $allDates = implode(',', $allDates); - - $this->getApiToInvalidateArchivedReport()->invalidateArchivedReports($idSiteToInvalidate, $allDates, $period = false, $info['segment']); - } - $this->setInvalidationTime(); $this->logger->debug("Done invalidating"); diff --git a/core/CronArchive/SegmentArchiving.php b/core/CronArchive/SegmentArchiving.php index 1e68b3639f..923f3d4004 100644 --- a/core/CronArchive/SegmentArchiving.php +++ b/core/CronArchive/SegmentArchiving.php @@ -9,6 +9,8 @@ namespace Piwik\CronArchive; use Doctrine\Common\Cache\Cache; use Matomo\Cache\Transient; +use Piwik\Access; +use Piwik\Archive\ArchiveInvalidator; use Piwik\ArchiveProcessor\Rules; use Piwik\Common; use Piwik\Container\StaticContainer; @@ -65,11 +67,11 @@ class SegmentArchiving */ private $forceArchiveAllSegments; - public function __construct($processNewSegmentsFrom, $beginningOfTimeLastNInYears = self::DEFAULT_BEGINNING_OF_TIME_LAST_N_YEARS, + public function __construct($beginningOfTimeLastNInYears = self::DEFAULT_BEGINNING_OF_TIME_LAST_N_YEARS, Model $segmentEditorModel = null, Cache $segmentListCache = null, Date $now = null, LoggerInterface $logger = null) { - $this->processNewSegmentsFrom = $processNewSegmentsFrom; + $this->processNewSegmentsFrom = StaticContainer::get('ini.General.process_new_segments_from'); $this->beginningOfTimeLastNInYears = $beginningOfTimeLastNInYears; $this->segmentEditorModel = $segmentEditorModel ?: new Model(); $this->segmentListCache = $segmentListCache ?: new Transient(); @@ -78,48 +80,6 @@ class SegmentArchiving $this->forceArchiveAllSegments = $this->getShouldForceArchiveAllSegments(); } - public function getSegmentArchivesToInvalidateForNewSegments($idSite) - { - return $this->getSegmentArchivesToInvalidate($idSite, true); - } - - public function getSegmentArchivesToInvalidate($idSite, $checkOnlyForNewSegments = false) - { - $result = []; - - $segmentsForSite = $this->getAllSegments(); - foreach ($segmentsForSite as $storedSegment) { - if (!$this->isAutoArchivingEnabledFor($storedSegment) - || !$this->isSegmentForSite($storedSegment, $idSite) - ) { - continue; - } - - $oldestDateToProcessForNewSegment = $this->getOldestDateToProcessForNewSegment($idSite, $storedSegment, $checkOnlyForNewSegments); - if (empty($oldestDateToProcessForNewSegment)) { - continue; - } - - $found = false; - foreach ($result as $segment) { - if ($segment['segment'] == $storedSegment['definition']) { - $segment['date'] = $segment['date']->isEarlier($oldestDateToProcessForNewSegment) ? $segment['date'] : $oldestDateToProcessForNewSegment; - - $found = true; - break; - } - } - - if (!$found) { - $result[] = [ - 'date' => $oldestDateToProcessForNewSegment, - 'segment' => $storedSegment['definition'], - ]; - } - } - return $result; - } - public function findSegmentForHash($hash, $idSite) { foreach ($this->getAllSegments() as $segment) { @@ -143,50 +103,27 @@ class SegmentArchiving return null; } - private function getOldestDateToProcessForNewSegment($idSite, $storedSegment, $checkOnlyForNewSegments) + public function getReArchiveSegmentStartDate($segmentInfo) { /** * @var Date $segmentCreatedTime * @var Date $segmentLastEditedTime */ - list($segmentCreatedTime, $segmentLastEditedTime) = $this->getCreatedTimeOfSegment($idSite, $storedSegment); + list($segmentCreatedTime, $segmentLastEditedTime) = $this->getCreatedTimeOfSegment($segmentInfo); if (empty($segmentCreatedTime)) { return null; } - $lastInvalidationTime = CronArchive::getLastInvalidationTime(); - if (!empty($lastInvalidationTime)) { - $lastInvalidationTime = Date::factory((int) $lastInvalidationTime); - } - - $segmentTimeToUse = $segmentLastEditedTime ?: $segmentCreatedTime; - if ($checkOnlyForNewSegments) { - if (!empty($lastInvalidationTime) - && !empty($segmentTimeToUse) - && $segmentTimeToUse->isEarlier($lastInvalidationTime) - ) { - return null; // has already have been invalidated, ignore - } - } - - if ($this->processNewSegmentsFrom == self::CREATION_TIME) { + if ($this->processNewSegmentsFrom == SegmentArchiving::CREATION_TIME) { $this->logger->debug("process_new_segments_from set to segment_creation_time, oldest date to process is {time}", array('time' => $segmentCreatedTime)); return $segmentCreatedTime; - } elseif ($this->processNewSegmentsFrom == self::LAST_EDIT_TIME) { + } else if ($this->processNewSegmentsFrom == SegmentArchiving::LAST_EDIT_TIME) { $this->logger->debug("process_new_segments_from set to segment_last_edit_time, segment last edit time is {time}", array('time' => $segmentLastEditedTime)); - if ($segmentLastEditedTime === null - || $segmentLastEditedTime->getTimestamp() < $segmentCreatedTime->getTimestamp() - ) { - $this->logger->debug("segment last edit time is older than created time, using created time instead"); - - $segmentLastEditedTime = $segmentCreatedTime; - } - return $segmentLastEditedTime; - } elseif (preg_match("/^last([0-9]+)$/", $this->processNewSegmentsFrom, $matches)) { + } else if (preg_match("/^last([0-9]+)$/", $this->processNewSegmentsFrom, $matches)) { $lastN = $matches[1]; list($lastDate, $lastPeriod) = Range::getDateXPeriodsAgo($lastN, $segmentCreatedTime, 'day'); @@ -198,11 +135,15 @@ class SegmentArchiving } else { $this->logger->debug("process_new_segments_from set to beginning_of_time or cannot recognize value"); - $siteCreationDate = Date::factory(Site::getCreationDateFor($idSite)); - $result = Date::factory('today')->subYear($this->beginningOfTimeLastNInYears); - if ($result->isEarlier($siteCreationDate)) { - $result = $siteCreationDate; + + $idSite = $segmentInfo['enable_only_idsite'] ?? null; + if (!empty($idSite)) { + $siteCreationDate = Date::factory(Site::getCreationDateFor($idSite)); + + if ($result->isEarlier($siteCreationDate)) { + $result = $siteCreationDate; + } } $earliestVisitTime = $this->getEarliestVisitTimeFor($idSite); @@ -216,6 +157,22 @@ class SegmentArchiving } } + private function getCreatedTimeOfSegment($storedSegment) + { + // check for an earlier ts_created timestamp + $createdTime = empty($storedSegment['ts_created']) ? null : Date::factory($storedSegment['ts_created']); + + // if there is no ts_last_edit timestamp, initialize it to ts_created + if (empty($storedSegment['ts_last_edit'])) { + $storedSegment['ts_last_edit'] = empty($storedSegment['ts_created']) ? null : $storedSegment['ts_created']; + } + + // check for a later ts_last_edit timestamp + $lastEditTime = empty($storedSegment['ts_last_edit']) ? null : Date::factory($storedSegment['ts_last_edit']); + + return array($createdTime, $lastEditTime); + } + private function getEarliestVisitTimeFor($idSite) { $earliestIdVisit = Db::fetchOne('SELECT idvisit FROM ' . Common::prefixTable('log_visit') @@ -232,52 +189,6 @@ class SegmentArchiving return Date::factory($earliestStartTime); } - private function getCreatedTimeOfSegment($idSite, $storedSegment) - { - /** @var Date $latestEditTime */ - $latestEditTime = null; - $earliestCreatedTime = $this->now; - if (empty($storedSegment['ts_created']) - || empty($storedSegment['definition']) - || !isset($storedSegment['enable_only_idsite']) - || !$this->isSegmentForSite($storedSegment, $idSite) - ) { - return [null, null]; - } - - // check for an earlier ts_created timestamp - $createdTime = Date::factory($storedSegment['ts_created']); - if ($createdTime->getTimestamp() < $earliestCreatedTime->getTimestamp()) { - $earliestCreatedTime = $createdTime; - } - - // if there is no ts_last_edit timestamp, initialize it to ts_created - if (empty($storedSegment['ts_last_edit'])) { - $storedSegment['ts_last_edit'] = $storedSegment['ts_created']; - } - - // check for a later ts_last_edit timestamp - $lastEditTime = Date::factory($storedSegment['ts_last_edit']); - if ($latestEditTime === null - || $latestEditTime->getTimestamp() < $lastEditTime->getTimestamp() - ) { - $latestEditTime = $lastEditTime; - } - - $this->logger->debug( - "Earliest created time of segment '{segment}' w/ idSite = {idSite} is found to be {createdTime}. Latest " . - "edit time is found to be {latestEditTime}.", - array( - 'segment' => $storedSegment['definition'], - 'idSite' => $idSite, - 'createdTime' => $earliestCreatedTime, - 'latestEditTime' => $latestEditTime, - ) - ); - - return array($earliestCreatedTime, $latestEditTime); - } - public function getAllSegments() { if (!$this->segmentListCache->contains('all')) { @@ -309,4 +220,22 @@ class SegmentArchiving { return !Rules::isBrowserTriggerEnabled() && !Rules::isBrowserArchivingAvailableForSegments(); } + + public function reArchiveSegment($segmentInfo) + { + if (empty($segmentInfo['definition'])) { // sanity check + return; + } + + $definition = $segmentInfo['definition']; + $idSite = $segmentInfo['enable_only_idsite'] ?? 'all'; + + $idSites = Access::doAsSuperUser(function () use ($idSite) { + return Site::getIdSitesFromIdSitesString($idSite); + }); + $startDate = $this->getReArchiveSegmentStartDate($segmentInfo); + + $invalidator = StaticContainer::get(ArchiveInvalidator::class); + $invalidator->scheduleReArchiving($idSites, null, null, $startDate, new Segment($definition, $idSites)); + } } diff --git a/core/Updates/4.1.2-b1.php b/core/Updates/4.1.2-b1.php index fbd9d52fd8..8093bb9dcd 100644 --- a/core/Updates/4.1.2-b1.php +++ b/core/Updates/4.1.2-b1.php @@ -9,10 +9,12 @@ namespace Piwik\Updates; -use Piwik\Archive\ArchiveInvalidator; -use Piwik\ArchiveProcessor\Rules; use Piwik\Container\StaticContainer; +use Piwik\CronArchive; use Piwik\Date; +use Piwik\Plugins\SegmentEditor\API; +use Piwik\Archive\ArchiveInvalidator; +use Piwik\ArchiveProcessor\Rules; use Piwik\Updater; use Piwik\Updates as PiwikUpdates; use Piwik\Updater\Migration\Factory as MigrationFactory; @@ -29,6 +31,11 @@ class Updates_4_1_2_b1 extends PiwikUpdates $this->migration = $factory; } + public function doUpdate(Updater $updater) + { + $updater->executeMigrations(__FILE__, $this->getMigrations($updater)); + } + public function getMigrations(Updater $updater) { $migrations = []; @@ -44,12 +51,23 @@ class Updates_4_1_2_b1 extends PiwikUpdates }, $cmdStr); } - return $migrations; - } + $migrations[] = new Updater\Migration\Custom(function () { + $segmentArchiving = StaticContainer::get(CronArchive\SegmentArchiving::class); + $timeOfLastInvalidateTime = CronArchive::getLastInvalidationTime(); - public function doUpdate(Updater $updater) - { - $updater->executeMigrations(__FILE__, $this->getMigrations($updater)); + $segments = API::getInstance()->getAll(); + foreach ($segments as $segment) { + $tsCreated = !empty($segment['ts_created']) ? Date::factory($segment['ts_created'])->getTimestamp() : 0; + $tsLastEdit = !empty($segment['ts_last_edit']) ? Date::factory($segment['ts_last_edit'])->getTimestamp() : null; + $timeToUse = max($tsCreated, $tsLastEdit); + + if ($timeToUse > $timeOfLastInvalidateTime) { + $segmentArchiving->reArchiveSegment($segment); + } + } + }, ''); + + return $migrations; } private function getInvalidateCommand(Date $dateOfMatomo4Release) diff --git a/plugins/CoreConsole/tests/System/ArchiveCronTest.php b/plugins/CoreConsole/tests/System/ArchiveCronTest.php index 7886614f95..3b01828a12 100644 --- a/plugins/CoreConsole/tests/System/ArchiveCronTest.php +++ b/plugins/CoreConsole/tests/System/ArchiveCronTest.php @@ -9,6 +9,7 @@ namespace Piwik\Plugins\CoreConsole\tests\System; use Piwik\CronArchive; use Piwik\Plugins\SegmentEditor\API; +use Piwik\Site; use Piwik\Tests\Framework\TestingEnvironmentVariables; use Psr\Container\ContainerInterface; use Piwik\Archive\ArchiveInvalidator; @@ -53,6 +54,7 @@ class ArchiveCronTest extends SystemTestCase parent::setUpBeforeClass(); Db::exec("UPDATE " . Common::prefixTable('site') . ' SET ts_created = \'2005-01-02 00:00:00\''); + Site::clearCache(); } private static function addNewSegmentToPast() @@ -176,6 +178,9 @@ class ArchiveCronTest extends SystemTestCase $tracker->setUrl('http://example.com/test/url'); Fixture::checkResponse($tracker->doTrackPageView('abcdefg')); + $invalidationEntries = $this->getInvalidatedArchiveTableEntries(); + $this->assertGreaterThan(0, count($invalidationEntries)); + // empty the list so nothing is invalidated during core:archive (so we only archive ExamplePlugin and not all plugins) $invalidator->forgetRememberedArchivedReportsToInvalidate(1, Date::factory('2007-04-05')); diff --git a/plugins/SegmentEditor/API.php b/plugins/SegmentEditor/API.php index 56cbe91282..13f724782b 100644 --- a/plugins/SegmentEditor/API.php +++ b/plugins/SegmentEditor/API.php @@ -9,13 +9,20 @@ namespace Piwik\Plugins\SegmentEditor; use Exception; +use Piwik\Access; +use Piwik\Archive\ArchiveInvalidator; use Piwik\ArchiveProcessor\Rules; use Piwik\Common; +use Piwik\Container\StaticContainer; +use Piwik\CronArchive\SegmentArchiving; use Piwik\Date; use Piwik\Db; +use Piwik\Period\Range; use Piwik\Piwik; use Piwik\Config; use Piwik\Segment; +use Piwik\Site; +use Psr\Log\LoggerInterface; /** * The SegmentEditor API lets you add, update, delete custom Segments, and list saved segments. @@ -29,9 +36,18 @@ class API extends \Piwik\Plugin\API */ private $model; - public function __construct(Model $model) + /** + * @var SegmentArchiving + */ + private $segmentArchiving; + + private $processNewSegmentsFrom; + + public function __construct(Model $model, SegmentArchiving $segmentArchiving) { $this->model = $model; + $this->segmentArchiving = $segmentArchiving; + $this->processNewSegmentsFrom = StaticContainer::get('ini.General.process_new_segments_from'); } protected function checkSegmentValue($definition, $idSite) @@ -258,6 +274,10 @@ class API extends \Piwik\Plugin\API $this->getModel()->updateSegment($idSegment, $bind); + if ($autoArchive && !Rules::isBrowserTriggerEnabled()) { + $this->segmentArchiving->reArchiveSegment($bind); + } + return true; } @@ -294,6 +314,13 @@ class API extends \Piwik\Plugin\API $id = $this->getModel()->createSegment($bind); + if ($autoArchive + && !Rules::isBrowserTriggerEnabled() + && $this->processNewSegmentsFrom != SegmentArchiving::CREATION_TIME + ) { + $this->segmentArchiving->reArchiveSegment($bind); + } + return $id; } diff --git a/tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php b/tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php index 2eb1790980..919c063c37 100644 --- a/tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php +++ b/tests/PHPUnit/Integration/CronArchive/SegmentArchivingTest.php @@ -22,294 +22,102 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase; */ class SegmentArchivingTest extends IntegrationTestCase { - const TEST_NOW = '2015-03-01'; - - private $mockSegmentEntries; - - public function setUp(): void + protected static function beforeTableDataCached() { - parent::setUp(); - - Config::getInstance()->General['enabled_periods_API'] = 'day,week,month,year,range'; - - Site::setSites([ - 1 => [ - 'idsite' => 1, - 'ts_created' => '2013-03-03 00:00:00', - ], - ]); - - $this->mockSegmentEntries = array( - array( - 'ts_created' => '2014-01-01', - 'definition' => 'browserName==FF', - 'enable_only_idsite' => 1, - 'ts_last_edit' => '2014-05-05 00:22:33', - 'auto_archive' => 1, - ), - - array( - 'ts_created' => '2014-01-01', - 'definition' => 'countryCode==us', - 'enable_only_idsite' => 1, - 'ts_last_edit' => '2014-02-02 00:33:44', - 'auto_archive' => 1, - ), - - array( - 'ts_created' => '2012-01-01', - 'definition' => 'countryCode==us', - 'enable_only_idsite' => 1, - 'ts_last_edit' => '2014-02-03', - 'auto_archive' => 1, - ), - - array( - 'ts_created' => '2014-01-01', - 'definition' => 'countryCode==ca', - 'enable_only_idsite' => 2, - 'ts_last_edit' => '2013-01-01', - 'auto_archive' => 1, - ), - - array( - 'ts_created' => '2012-01-01', - 'definition' => 'countryCode==ca', - 'enable_only_idsite' => 2, - 'ts_last_edit' => '2011-01-01', - 'auto_archive' => 1, - ), - - array( - 'ts_created' => '2012-01-01', - 'definition' => 'countryCode==br', - 'enable_only_idsite' => 2, - 'ts_last_edit' => '2011-01-01', - 'auto_archive' => 1, - ), - - array( - 'ts_created' => '2011-01-01', - 'definition' => 'countryCode==ca', - 'enable_only_idsite' => 0, - 'ts_last_edit' => null, - 'auto_archive' => 1, - ), - - array( - 'ts_created' => '2015-03-01', - 'definition' => 'pageUrl==a', - 'enable_only_idsite' => 1, - 'ts_last_edit' => '2014-01-01', - 'auto_archive' => 1, - ), - - array( - 'ts_created' => '2015-02-01', - 'definition' => 'pageUrl==b', - 'enable_only_idsite' => 1, - 'ts_last_edit' => null, - 'auto_archive' => 1, - ), - ); - - Date::$now = strtotime('2020-01-30 00:00:00'); + parent::beforeTableDataCached(); + Fixture::createWebsite('2020-01-04 12:00:00'); } /** - * @dataProvider getTestDataForGetSegmentArchivesToInvalidateForNewSegments + * @dataProvider getTestDataForGetReArchiveSegmentStartDate */ - public function test_getSegmentArchivesToInvalidateForNewSegments_returnsAllSegments_IfInvalidationHasNotRun($processFrom, $idSite, $expected) + public function test_getReArchiveSegmentStartDate($processNewSegmentFrom, $segmentInfo, $expected) { - $archiving = $this->createUrlProviderToTest($processFrom); - $segments = $archiving->getSegmentArchivesToInvalidateForNewSegments($idSite); - $this->getStringDates($segments); - $this->assertEquals($expected, $segments); + Date::$now = strtotime('2020-10-12 13:45:00'); + + Config::getInstance()->General['process_new_segments_from'] = $processNewSegmentFrom; + + $segmentArchiving = new SegmentArchiving(); + $result = $segmentArchiving->getReArchiveSegmentStartDate($segmentInfo); + if (!empty($result)) { + $result = $result->toString(); + } + $this->assertEquals($expected, $result); } - public function getTestDataForGetSegmentArchivesToInvalidateForNewSegments() + public function getTestDataForGetReArchiveSegmentStartDate() { return [ + // no segment creation time [ - 'beginning_of_time', - 1, - [ - [ - 'date' => '2013-03-03 00:00:00', - 'segment' => 'browserName==FF', - ], - [ - 'date' => '2013-03-03 00:00:00', - 'segment' => 'countryCode==us', - ], - [ - 'date' => '2013-03-03 00:00:00', - 'segment' => 'countryCode==ca', - ], - [ - 'date' => '2013-03-03 00:00:00', - 'segment' => 'pageUrl==a', - ], - [ - 'date' => '2013-03-03 00:00:00', - 'segment' => 'pageUrl==b', - ], - ], + SegmentArchiving::CREATION_TIME, + [], + null, ], + // creation time [ - 'segment_creation_time', - 1, - [ - [ - 'date' => '2014-01-01 00:00:00', - 'segment' => 'browserName==FF', - ], - [ - 'date' => '2014-01-01 00:00:00', - 'segment' => 'countryCode==us', - ], - [ - 'date' => '2011-01-01 00:00:00', - 'segment' => 'countryCode==ca', - ], - [ - 'date' => '2015-03-01 00:00:00', - 'segment' => 'pageUrl==a', - ], - [ - 'date' => '2015-02-01 00:00:00', - 'segment' => 'pageUrl==b', - ], - ], + SegmentArchiving::CREATION_TIME, + ['ts_created' => '2020-04-12 03:34:55'], + '2020-04-12', ], + // last edit time [ - 'segment_last_edit_time', - 1, - [ - [ - 'date' => '2014-05-05 00:22:33', - 'segment' => 'browserName==FF', - ], - [ - 'date' => '2014-02-02 00:33:44', - 'segment' => 'countryCode==us', - ], - [ - 'date' => '2011-01-01 00:00:00', - 'segment' => 'countryCode==ca', - ], - [ - 'date' => '2015-03-01 00:00:00', - 'segment' => 'pageUrl==a', - ], - [ - 'date' => '2015-02-01 00:00:00', - 'segment' => 'pageUrl==b', - ], - ], + SegmentArchiving::LAST_EDIT_TIME, + ['ts_created' => '2020-02-02 03:00:00', 'ts_last_edit' => '2020-04-13 05:15:15'], + '2020-04-13', ], + // last edit time, no edit time in segment [ - 'segment_last_edit_time', - 2, - [ - [ - 'date' => '2014-01-01 00:00:00', - 'segment' => 'countryCode==ca', - ], - [ - 'date' => '2012-01-01 00:00:00', - 'segment' => 'countryCode==br', - ], - ], + SegmentArchiving::LAST_EDIT_TIME, + ['ts_created' => '2020-04-14 00:00:00'], + '2020-04-14', ], - ]; - } - - public function test_getSegmentArchivesToInvalidateForNewSegments_returnsSegmentsRecentlyCreated_IfInvalidationHasRun() - { - Option::set(CronArchive::CRON_INVALIDATION_TIME_OPTION_NAME, strtotime('2013-12-30 00:00:00')); - $archiving = $this->createUrlProviderToTest('beginning_of_time'); - $segments = $archiving->getSegmentArchivesToInvalidateForNewSegments(1); - $this->getStringDates($segments); - - $expected = [ - [ - 'segment' => 'browserName==FF', - 'date' => '2013-03-03 00:00:00', - ], + // lastN [ - 'segment' => 'countryCode==us', - 'date' => '2013-03-03 00:00:00', + 'last30', + ['ts_created' => '2020-06-12'], + '2020-05-13', ], + + // beginning of time [ - 'segment' => 'pageUrl==a', - 'date' => '2013-03-03 00:00:00', + SegmentArchiving::BEGINNING_OF_TIME, + ['ts_created' => '2020-06-12'], + '2013-01-01', ], + + // beginning of time (unreadable value) [ - 'segment' => 'pageUrl==b', - 'date' => '2013-03-03 00:00:00', + 'aslkdfjsdlkjf', + ['ts_created' => '2020-06-12'], + '2013-01-01', ], ]; - $this->assertEquals($expected, $segments); } - public function test_getSegmentArchivesToInvalidateForNewSegments_returnsNoSegments_IfInvalidationHasRunAndAllSegmentsCreatedBefore() + public function test_getReArchiveSegmentStartDate_whenSiteCreationDateIsLater() { - Option::set(CronArchive::CRON_INVALIDATION_TIME_OPTION_NAME, strtotime('2019-12-30 00:00:00')); - - $archiving = $this->createUrlProviderToTest('beginning_of_time'); - $segments = $archiving->getSegmentArchivesToInvalidateForNewSegments(1); - $this->getStringDates($segments); - - $expected = []; - $this->assertEquals($expected, $segments); - } - - public function test_getSegmentArchivesToInvalidateForNewSegments_usesLastArchiveFinishTimeIfInvalidationTimeMissing() - { - Option::set(CronArchive::OPTION_ARCHIVING_FINISHED_TS, strtotime('2013-12-30 00:00:00')); - - $archiving = $this->createUrlProviderToTest('beginning_of_time'); - $segments = $archiving->getSegmentArchivesToInvalidateForNewSegments(1); - $this->getStringDates($segments); - - $expected = [ - [ - 'segment' => 'browserName==FF', - 'date' => '2013-03-03 00:00:00', - ], - [ - 'segment' => 'countryCode==us', - 'date' => '2013-03-03 00:00:00', - ], - [ - 'segment' => 'pageUrl==a', - 'date' => '2013-03-03 00:00:00', - ], - [ - 'segment' => 'pageUrl==b', - 'date' => '2013-03-03 00:00:00', - ], - ]; - $this->assertEquals($expected, $segments); + $segmentInfo = ['ts_created' => '2019-05-03 00:00:00', 'enable_only_idsite' => 1]; + $this->test_getReArchiveSegmentStartDate(SegmentArchiving::BEGINNING_OF_TIME, $segmentInfo, '2020-01-03'); } - private function createUrlProviderToTest($processNewSegmentsFrom, $mockData = null) + public function test_getReArchiveSegmentStartDate_whenEarliestVisitTimeIsLater() { - $mockSegmentEditorModel = $this->createPartialMock('Piwik\Plugins\SegmentEditor\Model', array('getAllSegmentsAndIgnoreVisibility')); - $mockSegmentEditorModel->expects($this->any())->method('getAllSegmentsAndIgnoreVisibility')->will($this->returnValue($mockData ?: $this->mockSegmentEntries)); + $t = Fixture::getTracker(1, '2020-02-05 03:00:00'); + $t->setUrl('http://abc.com'); + Fixture::checkResponse($t->doTrackPageView('abc')); - return new SegmentArchiving($processNewSegmentsFrom, $beginningOfTimeLastN = 7, $mockSegmentEditorModel, null, Date::factory(self::TEST_NOW)); + $segmentInfo = ['ts_created' => '2019-05-03 00:00:00', 'enable_only_idsite' => 1]; + $this->test_getReArchiveSegmentStartDate(SegmentArchiving::BEGINNING_OF_TIME, $segmentInfo, '2020-02-05'); } - private function getStringDates(array &$entries) + protected static function configureFixture($fixture) { - foreach ($entries as &$entry) { - $entry['date'] = $entry['date']->getDatetime(); - } + parent::configureFixture($fixture); + $fixture->createSuperUser = true; } }
\ No newline at end of file diff --git a/tests/PHPUnit/Integration/CronArchiveTest.php b/tests/PHPUnit/Integration/CronArchiveTest.php index 2fc991e7b4..06c93187d2 100644 --- a/tests/PHPUnit/Integration/CronArchiveTest.php +++ b/tests/PHPUnit/Integration/CronArchiveTest.php @@ -544,7 +544,7 @@ class CronArchiveTest extends IntegrationTestCase $api = API::getInstance(); - $cronarchive = new TestCronArchive(Fixture::getRootUrl() . 'tests/PHPUnit/proxy/index.php'); + $cronarchive = new TestCronArchive(); $cronarchive->init(); $cronarchive->setApiToInvalidateArchivedReport($api); $cronarchive->invalidateArchivedReportsForSitesThatNeedToBeArchivedAgain(1); @@ -588,7 +588,7 @@ class CronArchiveTest extends IntegrationTestCase $allSegments = $segments->getSegmentsToAutoArchive(1); - $cronarchive = new TestCronArchive(Fixture::getRootUrl() . 'tests/PHPUnit/proxy/index.php'); + $cronarchive = new TestCronArchive(); $this->assertTrue($cronarchive->wasSegmentChangedRecently('actions>=1', $allSegments)); // created 30 hours ago... @@ -615,7 +615,7 @@ class CronArchiveTest extends IntegrationTestCase $logger = new FakeLogger(); - $archiver = new CronArchive(null, $logger); + $archiver = new CronArchive($logger); $archiver->init(); $archiveFilter = new CronArchive\ArchiveFilter(); $archiveFilter->setSkipSegmentsForToday(true); @@ -626,7 +626,6 @@ class CronArchiveTest extends IntegrationTestCase $archiver->run(); self::assertStringContainsString('Will skip segments archiving for today unless they were created recently', $logger->output); - self::assertStringContainsString('Segment "actions>=1" was created or changed recently and will therefore archive today', $logger->output); self::assertStringNotContainsString('Segment "actions>=2" was created recently', $logger->output); } @@ -660,7 +659,7 @@ class CronArchiveTest extends IntegrationTestCase $logger = new FakeLogger(); - $archiver = new CronArchive(null, $logger); + $archiver = new CronArchive($logger); $archiveFilter = new CronArchive\ArchiveFilter(); $archiveFilter->setSegmentsToForce(['actions>=2;browserCode=FF', 'actions>=2']); @@ -695,34 +694,32 @@ Checking for queued invalidations... Will invalidate archived reports for 2019-12-02 for following websites ids: 1 Today archive can be skipped due to no visits for idSite = 1, skipping invalidation... Yesterday archive can be skipped due to no visits for idSite = 1, skipping invalidation... - Segment "actions>=2" was created or changed recently and will therefore archive today (for site ID = 1) - Segment "actions>=4" was created or changed recently and will therefore archive today (for site ID = 1) Done invalidating -Processing invalidation: [idinvalidation = 9, idsite = 1, period = day(2019-12-12 - 2019-12-12), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. -Processing invalidation: [idinvalidation = 15, idsite = 1, period = day(2019-12-11 - 2019-12-11), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. -Processing invalidation: [idinvalidation = 18, idsite = 1, period = day(2019-12-10 - 2019-12-10), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. +Processing invalidation: [idinvalidation = 269, idsite = 1, period = day(2019-12-12 - 2019-12-12), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. +Processing invalidation: [idinvalidation = 268, idsite = 1, period = day(2019-12-11 - 2019-12-11), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. +Processing invalidation: [idinvalidation = 267, idsite = 1, period = day(2019-12-10 - 2019-12-10), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. Starting archiving for ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=day&date=2019-12-12&format=json&segment=actions%3E%3D2&trigger=archivephp Starting archiving for ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=day&date=2019-12-11&format=json&segment=actions%3E%3D2&trigger=archivephp Starting archiving for ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=day&date=2019-12-10&format=json&segment=actions%3E%3D2&trigger=archivephp Archived website id 1, period = day, date = 2019-12-12, segment = 'actions>=2', 0 visits found. Time elapsed: %fs Archived website id 1, period = day, date = 2019-12-11, segment = 'actions>=2', 0 visits found. Time elapsed: %fs Archived website id 1, period = day, date = 2019-12-10, segment = 'actions>=2', 0 visits found. Time elapsed: %fs -Processing invalidation: [idinvalidation = 10, idsite = 1, period = week(2019-12-09 - 2019-12-15), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. -Processing invalidation: [idinvalidation = 25, idsite = 1, period = day(2019-12-02 - 2019-12-02), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. +Processing invalidation: [idinvalidation = 266, idsite = 1, period = week(2019-12-09 - 2019-12-15), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. +Processing invalidation: [idinvalidation = 257, idsite = 1, period = day(2019-12-02 - 2019-12-02), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. No next invalidated archive. Starting archiving for ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=week&date=2019-12-09&format=json&segment=actions%3E%3D2&trigger=archivephp Starting archiving for ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=day&date=2019-12-02&format=json&segment=actions%3E%3D2&trigger=archivephp Archived website id 1, period = week, date = 2019-12-09, segment = 'actions>=2', 0 visits found. Time elapsed: %fs Archived website id 1, period = day, date = 2019-12-02, segment = 'actions>=2', 0 visits found. Time elapsed: %fs -Processing invalidation: [idinvalidation = 26, idsite = 1, period = week(2019-12-02 - 2019-12-08), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. +Processing invalidation: [idinvalidation = 258, idsite = 1, period = week(2019-12-02 - 2019-12-08), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. No next invalidated archive. Starting archiving for ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=week&date=2019-12-02&format=json&segment=actions%3E%3D2&trigger=archivephp Archived website id 1, period = week, date = 2019-12-02, segment = 'actions>=2', 0 visits found. Time elapsed: %fs -Processing invalidation: [idinvalidation = 11, idsite = 1, period = month(2019-12-01 - 2019-12-31), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. +Processing invalidation: [idinvalidation = 256, idsite = 1, period = month(2019-12-01 - 2019-12-31), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. No next invalidated archive. Starting archiving for ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=month&date=2019-12-01&format=json&segment=actions%3E%3D2&trigger=archivephp Archived website id 1, period = month, date = 2019-12-01, segment = 'actions>=2', 0 visits found. Time elapsed: %fs -Processing invalidation: [idinvalidation = 12, idsite = 1, period = year(2019-01-01 - 2019-12-31), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. +Processing invalidation: [idinvalidation = 65, idsite = 1, period = year(2019-01-01 - 2019-12-31), name = donee0512c03f7c20af6ef96a8d792c6bb9f, segment = actions>=2]. No next invalidated archive. Starting archiving for ?module=API&method=CoreAdminHome.archiveReports&idSite=1&period=year&date=2019-01-01&format=json&segment=actions%3E%3D2&trigger=archivephp Archived website id 1, period = year, date = 2019-01-01, segment = 'actions>=2', 0 visits found. Time elapsed: %fs @@ -777,7 +774,7 @@ LOG; $sequence = new Sequence(ArchiveTableCreator::getNumericTable(Date::factory('2019-12-10'))); $sequence->create(); - $archiver = new CronArchive(null, $logger); + $archiver = new CronArchive($logger); $archiveFilter = new CronArchive\ArchiveFilter(); $archiver->setArchiveFilter($archiveFilter); @@ -867,7 +864,7 @@ LOG; $logger = new FakeLogger(); - $archiver = new CronArchive(null, $logger); + $archiver = new CronArchive($logger); $archiver->shouldArchiveSpecifiedSites = array(99999, 1); $archiver->init(); $archiver->run(); diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php index 8d1e75db00..f71d63f54d 100644 --- a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php +++ b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php @@ -97,8 +97,8 @@ class ArchiveInvalidatorTest extends IntegrationTestCase $items = $list->getAll(); $expected = [ - '{"idSites":[1],"pluginName":"ExamplePlugin","report":null,"startDate":null}', - '{"idSites":[1,4,5],"pluginName":"MyOtherPlugin","report":null,"startDate":null}', + '{"idSites":[1],"pluginName":"ExamplePlugin","report":null,"startDate":null,"segment":null}', + '{"idSites":[1,4,5],"pluginName":"MyOtherPlugin","report":null,"startDate":null,"segment":null}', ]; $this->assertEquals($expected, $items); @@ -115,7 +115,7 @@ class ArchiveInvalidatorTest extends IntegrationTestCase $items = $list->getAll(); $expected = [ - '{"idSites":[1,4,5],"pluginName":"MyOtherPlugin","report":null,"startDate":null}', + '{"idSites":[1,4,5],"pluginName":"MyOtherPlugin","report":null,"startDate":null,"segment":null}', ]; $this->assertEquals($expected, $items); @@ -149,8 +149,8 @@ class ArchiveInvalidatorTest extends IntegrationTestCase $items = $list->getAll(); $expected = [ - '{"idSites":[1,4,5],"pluginName":"ExamplePlugin","report":null,"startDate":null}', - '{"idSites":[1,4,5],"pluginName":"ExamplePlugin","report":"myOtherReport","startDate":null}', + '{"idSites":[1,4,5],"pluginName":"ExamplePlugin","report":null,"startDate":null,"segment":null}', + '{"idSites":[1,4,5],"pluginName":"ExamplePlugin","report":"myOtherReport","startDate":null,"segment":null}', ]; $this->assertEquals($expected, $items); @@ -404,7 +404,7 @@ class ArchiveInvalidatorTest extends IntegrationTestCase $this->assertSameReports($expected, $reports); } - public function test_markArchivesAsInvalidated_shouldForgetInvalidatedSitesAndDates() + public function test_markArchivesAsInvalidated_shouldForgetInvalidatedSitesAndDates_IfPeriodIsDay() { $this->rememberReportsForManySitesAndDates(); @@ -415,7 +415,7 @@ class ArchiveInvalidatorTest extends IntegrationTestCase Date::factory('2010-10-10'), ); - $this->invalidator->markArchivesAsInvalidated($idSites, $dates, 'week'); + $this->invalidator->markArchivesAsInvalidated($idSites, $dates, 'day'); $reports = $this->invalidator->getRememberedArchivedReportsThatShouldBeInvalidated(); $expected = array( @@ -1651,8 +1651,8 @@ class ArchiveInvalidatorTest extends IntegrationTestCase 'period' => '1', 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc.VisitsSummary', 'report' => 'some.Report', - 'dates' => '2020-05-04,2020-05-04|2020-05-05,2020-05-05|2020-05-06,2020-05-06|2020-05-07,2020-05-07|2020-05-08,2020-05-08|2020-05-09,2020-05-09|2020-05-10,2020-05-10|2020-05-11,2020-05-11|2020-05-12,2020-05-12|2020-05-13,2020-05-13|2020-05-14,2020-05-14|2020-05-15,2020-05-15|2020-05-16,2020-05-16|2020-05-17,2020-05-17|2020-05-18,2020-05-18|2020-05-19,2020-05-19|2020-05-20,2020-05-20|2020-05-21,2020-05-21|2020-05-22,2020-05-22|2020-05-23,2020-05-23|2020-05-24,2020-05-24|2020-05-25,2020-05-25|2020-05-26,2020-05-26|2020-05-27,2020-05-27|2020-05-28,2020-05-28|2020-05-29,2020-05-29|2020-05-30,2020-05-30|2020-05-31,2020-05-31|2020-06-01,2020-06-01|2020-06-02,2020-06-02|2020-06-03,2020-06-03|2020-06-04,2020-06-04|2020-06-05,2020-06-05|2020-06-06,2020-06-06|2020-06-07,2020-06-07|2020-06-08,2020-06-08|2020-06-09,2020-06-09|2020-06-10,2020-06-10|2020-06-11,2020-06-11|2020-06-12,2020-06-12|2020-06-13,2020-06-13|2020-06-14,2020-06-14', - 'count' => '42', + 'dates' => '2020-04-30,2020-04-30|2020-05-01,2020-05-01|2020-05-02,2020-05-02|2020-05-03,2020-05-03|2020-05-04,2020-05-04|2020-05-05,2020-05-05|2020-05-06,2020-05-06|2020-05-07,2020-05-07|2020-05-08,2020-05-08|2020-05-09,2020-05-09|2020-05-10,2020-05-10|2020-05-11,2020-05-11|2020-05-12,2020-05-12|2020-05-13,2020-05-13|2020-05-14,2020-05-14|2020-05-15,2020-05-15|2020-05-16,2020-05-16|2020-05-17,2020-05-17|2020-05-18,2020-05-18|2020-05-19,2020-05-19|2020-05-20,2020-05-20|2020-05-21,2020-05-21|2020-05-22,2020-05-22|2020-05-23,2020-05-23|2020-05-24,2020-05-24|2020-05-25,2020-05-25|2020-05-26,2020-05-26|2020-05-27,2020-05-27|2020-05-28,2020-05-28|2020-05-29,2020-05-29|2020-05-30,2020-05-30|2020-05-31,2020-05-31|2020-06-01,2020-06-01|2020-06-02,2020-06-02|2020-06-03,2020-06-03|2020-06-04,2020-06-04|2020-06-05,2020-06-05|2020-06-06,2020-06-06|2020-06-07,2020-06-07|2020-06-08,2020-06-08|2020-06-09,2020-06-09|2020-06-10,2020-06-10|2020-06-11,2020-06-11|2020-06-12,2020-06-12|2020-06-13,2020-06-13|2020-06-14,2020-06-14', + 'count' => '46', ), array ( 'idsite' => '11', @@ -1667,8 +1667,8 @@ class ArchiveInvalidatorTest extends IntegrationTestCase 'period' => '2', 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc.VisitsSummary', 'report' => 'some.Report', - 'dates' => '2020-05-04,2020-05-10|2020-05-11,2020-05-17|2020-05-18,2020-05-24|2020-05-25,2020-05-31|2020-06-01,2020-06-07|2020-06-08,2020-06-14', - 'count' => '6', + 'dates' => '2020-04-27,2020-05-03|2020-05-04,2020-05-10|2020-05-11,2020-05-17|2020-05-18,2020-05-24|2020-05-25,2020-05-31|2020-06-01,2020-06-07|2020-06-08,2020-06-14', + 'count' => '7', ), array ( 'idsite' => '11', @@ -1683,8 +1683,8 @@ class ArchiveInvalidatorTest extends IntegrationTestCase 'period' => '3', 'name' => 'done5f4f9bafeda3443c3c2d4b2ef4dffadc.VisitsSummary', 'report' => 'some.Report', - 'dates' => '2020-05-01,2020-05-31|2020-06-01,2020-06-30', - 'count' => '2', + 'dates' => '2020-04-01,2020-04-30|2020-05-01,2020-05-31|2020-06-01,2020-06-30', + 'count' => '3', ), array ( 'idsite' => '11', diff --git a/tests/PHPUnit/Integration/PluginTest.php b/tests/PHPUnit/Integration/PluginTest.php index 756749ee01..7ab46a8945 100644 --- a/tests/PHPUnit/Integration/PluginTest.php +++ b/tests/PHPUnit/Integration/PluginTest.php @@ -84,11 +84,11 @@ class PluginTest extends IntegrationTestCase $item = reset($items); $item = json_decode($item, $assocc = true); - $date = end($item); - if (empty($date)) { - return $date; + if (empty($item['startDate'])) { + return null; } + $date = $item['startDate']; return Date::factory($date)->getDatetime(); } diff --git a/tests/PHPUnit/System/ArchiveInvalidationTest.php b/tests/PHPUnit/System/ArchiveInvalidationTest.php index bb1e9e6083..95d756c2ce 100644 --- a/tests/PHPUnit/System/ArchiveInvalidationTest.php +++ b/tests/PHPUnit/System/ArchiveInvalidationTest.php @@ -52,7 +52,7 @@ class ArchiveInvalidationTest extends SystemTestCase return array( array($apiToCall, array('idSite' => self::$fixture->idSite2, - 'testSuffix' => 'Website' . self::$fixture->idSite2 . "_NewDataShouldNotAppear_BecauseDayWasNotInvalidated", + 'testSuffix' => 'Website' . self::$fixture->idSite2 . $this->suffix, 'date' => self::$fixture->dateTimeFirstDateWebsite2, 'periods' => 'day', 'segment' => 'pageUrl=@category/', @@ -135,7 +135,8 @@ class ArchiveInvalidationTest extends SystemTestCase $r = new Request("module=API&method=CoreAdminHome.invalidateArchivedReports&idSites=" . self::$fixture->idSite1 . "&dates=" . $dateToInvalidate1->format('Y-m-d')); $this->assertApiResponseHasNoError($r->process()); - // week reports only are invalidated and we test our daily report will still show old data. + // week reports only are invalidated. we test our daily report will show new data, even though weekly reports only are invalidated, + // because when we track data, it invalidates day periods as well. $this->invalidateTestArchive(self::$fixture->idSite2, 'week', self::$fixture->dateTimeFirstDateWebsite2); } diff --git a/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldAppear__Actions.getPageUrls_day.xml b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldAppear__Actions.getPageUrls_day.xml new file mode 100644 index 0000000000..e91a63b485 --- /dev/null +++ b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldAppear__Actions.getPageUrls_day.xml @@ -0,0 +1,173 @@ +<?xml version="1.0" encoding="utf-8" ?> +<results> + <result date="2010-01-06"> + <row> + <label>category</label> + <nb_visits>6</nb_visits> + <nb_hits>9</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <entry_nb_visits>2</entry_nb_visits> + <entry_nb_actions>18</entry_nb_actions> + <entry_sum_visit_length>2</entry_sum_visit_length> + <entry_bounce_count>0</entry_bounce_count> + <avg_bandwidth>0</avg_bandwidth> + <avg_page_load_time>0</avg_page_load_time> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <segment>pageUrl=^http%253A%252F%252Fpiwik.net%252Fcategory</segment> + <subtable> + <row> + <label>/Page1</label> + <nb_visits>2</nb_visits> + <nb_uniq_visitors>3</nb_uniq_visitors> + <nb_hits>3</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <entry_nb_uniq_visitors>2</entry_nb_uniq_visitors> + <entry_nb_visits>2</entry_nb_visits> + <entry_nb_actions>18</entry_nb_actions> + <entry_sum_visit_length>2</entry_sum_visit_length> + <entry_bounce_count>0</entry_bounce_count> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/category/Page1</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252Fcategory%252FPage1</segment> + </row> + <row> + <label>/Page2</label> + <nb_visits>2</nb_visits> + <nb_uniq_visitors>3</nb_uniq_visitors> + <nb_hits>3</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/category/Page2</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252Fcategory%252FPage2</segment> + </row> + <row> + <label>/NewPage</label> + <nb_visits>1</nb_visits> + <nb_uniq_visitors>2</nb_uniq_visitors> + <nb_hits>2</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/category/NewPage</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252Fcategory%252FNewPage</segment> + </row> + <row> + <label>/Page3</label> + <nb_visits>1</nb_visits> + <nb_uniq_visitors>1</nb_uniq_visitors> + <nb_hits>1</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/category/Page3</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252Fcategory%252FPage3</segment> + </row> + </subtable> + </row> + <row> + <label>/Contact</label> + <nb_visits>2</nb_visits> + <nb_uniq_visitors>3</nb_uniq_visitors> + <nb_hits>3</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <avg_bandwidth>0</avg_bandwidth> + <avg_page_load_time>0</avg_page_load_time> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/Contact</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252FContact</segment> + </row> + <row> + <label>/Home</label> + <nb_visits>2</nb_visits> + <nb_uniq_visitors>3</nb_uniq_visitors> + <nb_hits>3</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <avg_bandwidth>0</avg_bandwidth> + <avg_page_load_time>0</avg_page_load_time> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/Home</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252FHome</segment> + </row> + <row> + <label>Contact</label> + <nb_visits>2</nb_visits> + <nb_hits>3</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <exit_nb_visits>2</exit_nb_visits> + <avg_bandwidth>0</avg_bandwidth> + <avg_page_load_time>0</avg_page_load_time> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>100%</exit_rate> + <segment>pageUrl=^http%253A%252F%252Fpiwik.net%252FContact</segment> + <subtable> + <row> + <label>/ThankYou</label> + <nb_visits>2</nb_visits> + <nb_uniq_visitors>3</nb_uniq_visitors> + <nb_hits>3</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <exit_nb_uniq_visitors>2</exit_nb_uniq_visitors> + <exit_nb_visits>2</exit_nb_visits> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>100%</exit_rate> + <url>http://example.org/Contact/ThankYou</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252FContact%252FThankYou</segment> + </row> + </subtable> + </row> + </result> + <result date="2010-01-07" /> + <result date="2010-01-08" /> + <result date="2010-01-09" /> + <result date="2010-01-10" /> +</results>
\ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldAppear__VisitsSummary.get_day.xml b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldAppear__VisitsSummary.get_day.xml new file mode 100644 index 0000000000..bfd375c5c9 --- /dev/null +++ b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldAppear__VisitsSummary.get_day.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<results> + <result date="2010-01-06"> + <nb_uniq_visitors>2</nb_uniq_visitors> + <nb_users>0</nb_users> + <nb_visits>2</nb_visits> + <nb_actions>18</nb_actions> + <nb_visits_converted>0</nb_visits_converted> + <bounce_count>0</bounce_count> + <sum_visit_length>2</sum_visit_length> + <max_actions>12</max_actions> + <bounce_rate>0%</bounce_rate> + <nb_actions_per_visit>9</nb_actions_per_visit> + <avg_time_on_site>1</avg_time_on_site> + </result> + <result date="2010-01-07" /> + <result date="2010-01-08" /> + <result date="2010-01-09" /> + <result date="2010-01-10" /> +</results>
\ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear_BecauseDayWasNotInvalidated__Actions.getPageUrls_day.xml b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear_BecauseDayWasNotInvalidated__Actions.getPageUrls_day.xml index b3a70db9d0..e91a63b485 100644 --- a/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear_BecauseDayWasNotInvalidated__Actions.getPageUrls_day.xml +++ b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear_BecauseDayWasNotInvalidated__Actions.getPageUrls_day.xml @@ -3,16 +3,16 @@ <result date="2010-01-06"> <row> <label>category</label> - <nb_visits>3</nb_visits> - <nb_hits>3</nb_hits> + <nb_visits>6</nb_visits> + <nb_hits>9</nb_hits> <sum_time_spent>0</sum_time_spent> <sum_bandwidth>0</sum_bandwidth> <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> <min_bandwidth /> <max_bandwidth /> - <entry_nb_visits>1</entry_nb_visits> - <entry_nb_actions>6</entry_nb_actions> - <entry_sum_visit_length>1</entry_sum_visit_length> + <entry_nb_visits>2</entry_nb_visits> + <entry_nb_actions>18</entry_nb_actions> + <entry_sum_visit_length>2</entry_sum_visit_length> <entry_bounce_count>0</entry_bounce_count> <avg_bandwidth>0</avg_bandwidth> <avg_page_load_time>0</avg_page_load_time> @@ -23,18 +23,18 @@ <subtable> <row> <label>/Page1</label> - <nb_visits>1</nb_visits> - <nb_uniq_visitors>1</nb_uniq_visitors> - <nb_hits>1</nb_hits> + <nb_visits>2</nb_visits> + <nb_uniq_visitors>3</nb_uniq_visitors> + <nb_hits>3</nb_hits> <sum_time_spent>0</sum_time_spent> <sum_bandwidth>0</sum_bandwidth> <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> <min_bandwidth /> <max_bandwidth /> - <entry_nb_uniq_visitors>1</entry_nb_uniq_visitors> - <entry_nb_visits>1</entry_nb_visits> - <entry_nb_actions>6</entry_nb_actions> - <entry_sum_visit_length>1</entry_sum_visit_length> + <entry_nb_uniq_visitors>2</entry_nb_uniq_visitors> + <entry_nb_visits>2</entry_nb_visits> + <entry_nb_actions>18</entry_nb_actions> + <entry_sum_visit_length>2</entry_sum_visit_length> <entry_bounce_count>0</entry_bounce_count> <avg_time_on_page>0</avg_time_on_page> <bounce_rate>0%</bounce_rate> @@ -44,9 +44,9 @@ </row> <row> <label>/Page2</label> - <nb_visits>1</nb_visits> - <nb_uniq_visitors>1</nb_uniq_visitors> - <nb_hits>1</nb_hits> + <nb_visits>2</nb_visits> + <nb_uniq_visitors>3</nb_uniq_visitors> + <nb_hits>3</nb_hits> <sum_time_spent>0</sum_time_spent> <sum_bandwidth>0</sum_bandwidth> <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> @@ -59,6 +59,22 @@ <segment>pageUrl==http%253A%252F%252Fexample.org%252Fcategory%252FPage2</segment> </row> <row> + <label>/NewPage</label> + <nb_visits>1</nb_visits> + <nb_uniq_visitors>2</nb_uniq_visitors> + <nb_hits>2</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/category/NewPage</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252Fcategory%252FNewPage</segment> + </row> + <row> <label>/Page3</label> <nb_visits>1</nb_visits> <nb_uniq_visitors>1</nb_uniq_visitors> @@ -78,9 +94,9 @@ </row> <row> <label>/Contact</label> - <nb_visits>1</nb_visits> - <nb_uniq_visitors>1</nb_uniq_visitors> - <nb_hits>1</nb_hits> + <nb_visits>2</nb_visits> + <nb_uniq_visitors>3</nb_uniq_visitors> + <nb_hits>3</nb_hits> <sum_time_spent>0</sum_time_spent> <sum_bandwidth>0</sum_bandwidth> <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> @@ -96,9 +112,9 @@ </row> <row> <label>/Home</label> - <nb_visits>1</nb_visits> - <nb_uniq_visitors>1</nb_uniq_visitors> - <nb_hits>1</nb_hits> + <nb_visits>2</nb_visits> + <nb_uniq_visitors>3</nb_uniq_visitors> + <nb_hits>3</nb_hits> <sum_time_spent>0</sum_time_spent> <sum_bandwidth>0</sum_bandwidth> <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> @@ -114,14 +130,14 @@ </row> <row> <label>Contact</label> - <nb_visits>1</nb_visits> - <nb_hits>1</nb_hits> + <nb_visits>2</nb_visits> + <nb_hits>3</nb_hits> <sum_time_spent>0</sum_time_spent> <sum_bandwidth>0</sum_bandwidth> <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> <min_bandwidth /> <max_bandwidth /> - <exit_nb_visits>1</exit_nb_visits> + <exit_nb_visits>2</exit_nb_visits> <avg_bandwidth>0</avg_bandwidth> <avg_page_load_time>0</avg_page_load_time> <avg_time_on_page>0</avg_time_on_page> @@ -131,16 +147,16 @@ <subtable> <row> <label>/ThankYou</label> - <nb_visits>1</nb_visits> - <nb_uniq_visitors>1</nb_uniq_visitors> - <nb_hits>1</nb_hits> + <nb_visits>2</nb_visits> + <nb_uniq_visitors>3</nb_uniq_visitors> + <nb_hits>3</nb_hits> <sum_time_spent>0</sum_time_spent> <sum_bandwidth>0</sum_bandwidth> <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> <min_bandwidth /> <max_bandwidth /> - <exit_nb_uniq_visitors>1</exit_nb_uniq_visitors> - <exit_nb_visits>1</exit_nb_visits> + <exit_nb_uniq_visitors>2</exit_nb_uniq_visitors> + <exit_nb_visits>2</exit_nb_visits> <avg_time_on_page>0</avg_time_on_page> <bounce_rate>0%</bounce_rate> <exit_rate>100%</exit_rate> diff --git a/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear_BecauseDayWasNotInvalidated__VisitsSummary.get_day.xml b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear_BecauseDayWasNotInvalidated__VisitsSummary.get_day.xml index 241f0a7a02..bfd375c5c9 100644 --- a/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear_BecauseDayWasNotInvalidated__VisitsSummary.get_day.xml +++ b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear_BecauseDayWasNotInvalidated__VisitsSummary.get_day.xml @@ -1,16 +1,16 @@ <?xml version="1.0" encoding="utf-8" ?> <results> <result date="2010-01-06"> - <nb_uniq_visitors>1</nb_uniq_visitors> + <nb_uniq_visitors>2</nb_uniq_visitors> <nb_users>0</nb_users> - <nb_visits>1</nb_visits> - <nb_actions>6</nb_actions> + <nb_visits>2</nb_visits> + <nb_actions>18</nb_actions> <nb_visits_converted>0</nb_visits_converted> <bounce_count>0</bounce_count> - <sum_visit_length>1</sum_visit_length> - <max_actions>6</max_actions> + <sum_visit_length>2</sum_visit_length> + <max_actions>12</max_actions> <bounce_rate>0%</bounce_rate> - <nb_actions_per_visit>6</nb_actions_per_visit> + <nb_actions_per_visit>9</nb_actions_per_visit> <avg_time_on_site>1</avg_time_on_site> </result> <result date="2010-01-07" /> diff --git a/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear__Actions.getPageUrls_day.xml b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear__Actions.getPageUrls_day.xml new file mode 100644 index 0000000000..b3a70db9d0 --- /dev/null +++ b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear__Actions.getPageUrls_day.xml @@ -0,0 +1,157 @@ +<?xml version="1.0" encoding="utf-8" ?> +<results> + <result date="2010-01-06"> + <row> + <label>category</label> + <nb_visits>3</nb_visits> + <nb_hits>3</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <entry_nb_visits>1</entry_nb_visits> + <entry_nb_actions>6</entry_nb_actions> + <entry_sum_visit_length>1</entry_sum_visit_length> + <entry_bounce_count>0</entry_bounce_count> + <avg_bandwidth>0</avg_bandwidth> + <avg_page_load_time>0</avg_page_load_time> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <segment>pageUrl=^http%253A%252F%252Fpiwik.net%252Fcategory</segment> + <subtable> + <row> + <label>/Page1</label> + <nb_visits>1</nb_visits> + <nb_uniq_visitors>1</nb_uniq_visitors> + <nb_hits>1</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <entry_nb_uniq_visitors>1</entry_nb_uniq_visitors> + <entry_nb_visits>1</entry_nb_visits> + <entry_nb_actions>6</entry_nb_actions> + <entry_sum_visit_length>1</entry_sum_visit_length> + <entry_bounce_count>0</entry_bounce_count> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/category/Page1</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252Fcategory%252FPage1</segment> + </row> + <row> + <label>/Page2</label> + <nb_visits>1</nb_visits> + <nb_uniq_visitors>1</nb_uniq_visitors> + <nb_hits>1</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/category/Page2</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252Fcategory%252FPage2</segment> + </row> + <row> + <label>/Page3</label> + <nb_visits>1</nb_visits> + <nb_uniq_visitors>1</nb_uniq_visitors> + <nb_hits>1</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/category/Page3</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252Fcategory%252FPage3</segment> + </row> + </subtable> + </row> + <row> + <label>/Contact</label> + <nb_visits>1</nb_visits> + <nb_uniq_visitors>1</nb_uniq_visitors> + <nb_hits>1</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <avg_bandwidth>0</avg_bandwidth> + <avg_page_load_time>0</avg_page_load_time> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/Contact</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252FContact</segment> + </row> + <row> + <label>/Home</label> + <nb_visits>1</nb_visits> + <nb_uniq_visitors>1</nb_uniq_visitors> + <nb_hits>1</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <avg_bandwidth>0</avg_bandwidth> + <avg_page_load_time>0</avg_page_load_time> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>0%</exit_rate> + <url>http://example.org/Home</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252FHome</segment> + </row> + <row> + <label>Contact</label> + <nb_visits>1</nb_visits> + <nb_hits>1</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <exit_nb_visits>1</exit_nb_visits> + <avg_bandwidth>0</avg_bandwidth> + <avg_page_load_time>0</avg_page_load_time> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>100%</exit_rate> + <segment>pageUrl=^http%253A%252F%252Fpiwik.net%252FContact</segment> + <subtable> + <row> + <label>/ThankYou</label> + <nb_visits>1</nb_visits> + <nb_uniq_visitors>1</nb_uniq_visitors> + <nb_hits>1</nb_hits> + <sum_time_spent>0</sum_time_spent> + <sum_bandwidth>0</sum_bandwidth> + <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> + <min_bandwidth /> + <max_bandwidth /> + <exit_nb_uniq_visitors>1</exit_nb_uniq_visitors> + <exit_nb_visits>1</exit_nb_visits> + <avg_time_on_page>0</avg_time_on_page> + <bounce_rate>0%</bounce_rate> + <exit_rate>100%</exit_rate> + <url>http://example.org/Contact/ThankYou</url> + <segment>pageUrl==http%253A%252F%252Fexample.org%252FContact%252FThankYou</segment> + </row> + </subtable> + </row> + </result> + <result date="2010-01-07" /> + <result date="2010-01-08" /> + <result date="2010-01-09" /> + <result date="2010-01-10" /> +</results>
\ No newline at end of file diff --git a/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear__VisitsSummary.get_day.xml b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear__VisitsSummary.get_day.xml new file mode 100644 index 0000000000..241f0a7a02 --- /dev/null +++ b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldNotAppear__VisitsSummary.get_day.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<results> + <result date="2010-01-06"> + <nb_uniq_visitors>1</nb_uniq_visitors> + <nb_users>0</nb_users> + <nb_visits>1</nb_visits> + <nb_actions>6</nb_actions> + <nb_visits_converted>0</nb_visits_converted> + <bounce_count>0</bounce_count> + <sum_visit_length>1</sum_visit_length> + <max_actions>6</max_actions> + <bounce_rate>0%</bounce_rate> + <nb_actions_per_visit>6</nb_actions_per_visit> + <avg_time_on_site>1</avg_time_on_site> + </result> + <result date="2010-01-07" /> + <result date="2010-01-08" /> + <result date="2010-01-09" /> + <result date="2010-01-10" /> +</results>
\ No newline at end of file |