diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2020-08-20 23:55:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-20 23:55:05 +0300 |
commit | 8dfe273a96f681d0f8c6d1491bdd206cbaf8c04b (patch) | |
tree | ea9326665bbd8f4733192cd772d76048c0513f5c /plugins/ExamplePlugin | |
parent | e08e8551f316e299b47eda5e3ce550ef3ff8265a (diff) |
add convenience method for handling partial archiving in Archiver.php (#16326)
* convenience method
* fixing build
Diffstat (limited to 'plugins/ExamplePlugin')
-rw-r--r-- | plugins/ExamplePlugin/Archiver.php | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/plugins/ExamplePlugin/Archiver.php b/plugins/ExamplePlugin/Archiver.php index 13455ce6eb..89d79959b9 100644 --- a/plugins/ExamplePlugin/Archiver.php +++ b/plugins/ExamplePlugin/Archiver.php @@ -52,8 +52,8 @@ class Archiver extends \Piwik\Plugin\Archiver { parent::__construct($processor); - $this->requestedReport = $processor->getParams()->getArchiveOnlyReport(); - if ($this->requestedReport) { + $requestedReport = $processor->getParams()->getArchiveOnlyReport(); + if ($requestedReport) { $processor->getParams()->setIsPartialArchive(true); } @@ -74,7 +74,7 @@ class Archiver extends \Piwik\Plugin\Archiver * $this->getProcessor()->insertBlobRecord(self::EXAMPLEPLUGIN_ARCHIVE_RECORD, $visitorReport); */ - if ($this->isArchiving(self::EXAMPLEPLUGIN_METRIC_NAME)) { + if ($this->isRequestedReport(self::EXAMPLEPLUGIN_METRIC_NAME)) { // insert a test numeric metric that is the difference in days between the day we're archiving and // $this->daysFrom. $daysFrom = Date::factory($this->daysFrom); @@ -86,7 +86,7 @@ class Archiver extends \Piwik\Plugin\Archiver $this->getProcessor()->insertNumericRecord(self::EXAMPLEPLUGIN_METRIC_NAME, $differenceInDays); } - if ($this->isArchiving(self::EXAMPLEPLUGIN_CONST_METRIC_NAME)) { + if ($this->isRequestedReport(self::EXAMPLEPLUGIN_CONST_METRIC_NAME)) { $archiveCount = $this->incrementArchiveCount(); $archiveCount = 50 + $archiveCount; $archiveCount += 5 - ($archiveCount % 5); // round up to nearest 5 multiple to avoid random test failures @@ -106,10 +106,10 @@ class Archiver extends \Piwik\Plugin\Archiver */ $reports = []; - if ($this->isArchiving(self::EXAMPLEPLUGIN_METRIC_NAME)) { + if ($this->isRequestedReport(self::EXAMPLEPLUGIN_METRIC_NAME)) { $reports[] = self::EXAMPLEPLUGIN_METRIC_NAME; } - if ($this->isArchiving(self::EXAMPLEPLUGIN_CONST_METRIC_NAME)) { + if ($this->isRequestedReport(self::EXAMPLEPLUGIN_CONST_METRIC_NAME)) { $reports[] = self::EXAMPLEPLUGIN_CONST_METRIC_NAME; } $this->getProcessor()->aggregateNumericMetrics($reports); @@ -122,11 +122,6 @@ class Archiver extends \Piwik\Plugin\Archiver return $result; } - private function isArchiving(string $reportName) - { - return empty($this->requestedReport) || $this->requestedReport == $reportName; - } - private function createSequence() { $sequence = new Sequence('ExamplePlugin_archiveCount'); |