Skip to content

Commit

Permalink
use Archiver::getDependentSegmentsToArchive() in VisitFrequency (#20763)
Browse files Browse the repository at this point in the history
* introduce RecordBuilder concept and re-organize Goals archiving code via RecordBuilders

* fix loop iteration bug

* split ecommerce records recordbuilder into 3 separate records

* make sure Goals::getRecordMetadata() behaves like old archiver code

* make sure recordbuilder archive processor is restored after being used since archiving is a recursive process

* just make ArchiveProcessor a parameter

* check for plugin before calling buildMultiplePeriod()

* do not invoke record builders if archiver has no plugin (happens during tests)

* insert empty DataTables (as this appears to be the existing behavior before this change)

* add RecordBuilder class name to aggregation query hint

* clear up in-source todo

* attempt only archiving requested report if range archive and the record needed is created by a RecordBuilder

* refactor ArchiveSelector::getArchiveIds() to provide result with string keys

* when all found archives are partial archives, check that requested data is present within them. if some are not present, only archive those in a new partial archive.

* return correct value in Model::getRecordsContainedInArchives()

* fix if formatting

* existingArchives can be falsy

* existing archives can be null if the check is not relevant to the current archive request

* do not archive dependent segments if only processing the specific requested report

* fix more tests

* fix LoaderTest

* make sure if archiving specific reports for a single plugin that archiver class instances will not be created

* add filterRecordBuilders event

* if it looks like the requested records are numeric, prioritize the numeric archive table, otherwise blob archive table

* fix copy-paste error

* add dummy test for numeric values

* add test for partial archiving of numeric records for ranges and fix typo causing this to fail

* lessen code redundancy in Archive.php, use Piwik\\Request and do not yet mark RecordBuilder as api

* fix type hint

* fix php-cs errors

* fix failing tests

* fix failing tests (really)

* Add Archiver::getDependentSegmentsToArchive() so plugins do not have to implement aggregation methods in Archiver to process dependent archives.

* fix isEnabled calls

* only add idarchive to Archive.php idarchive cache if it is not already there (makes debugging a little less confusing)

* remove unneeded TODO

* when forcing new archive because timestamp is too old, do not report any existing archives

* report no existing archives if done flag is different + add tests

* update uses of ARCHIVE_DEPENDENT static variable

* allow dependent segments to specific different plugin than the one containing the archiver

* add dependent segments to archive for VisitFrequency

* add typehint

* Update Archiver.php
  • Loading branch information
diosmosis authored Jul 27, 2023
1 parent bb41633 commit 71ce1fc
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions plugins/VisitFrequency/Archiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@

class Archiver extends \Piwik\Plugin\Archiver
{
public function aggregateDayReport()
public function getDependentSegmentsToArchive(): array
{
$this->getProcessor()->processDependentArchive('VisitsSummary', VisitFrequencyAPI::NEW_VISITOR_SEGMENT);
$this->getProcessor()->processDependentArchive('VisitsSummary', VisitFrequencyAPI::RETURNING_VISITOR_SEGMENT);
}

public function aggregateMultipleReports()
{
$this->getProcessor()->processDependentArchive('VisitsSummary', VisitFrequencyAPI::NEW_VISITOR_SEGMENT);
$this->getProcessor()->processDependentArchive('VisitsSummary', VisitFrequencyAPI::RETURNING_VISITOR_SEGMENT);
return [
['plugin' => 'VisitsSummary', 'segment' => VisitFrequencyAPI::NEW_VISITOR_SEGMENT],
['plugin' => 'VisitsSummary', 'segment' => VisitFrequencyAPI::RETURNING_VISITOR_SEGMENT],
];
}
}

0 comments on commit 71ce1fc

Please sign in to comment.