diff --git a/plugins/ExamplePlugin/RecordBuilders/ExampleBlob.php b/plugins/ExamplePlugin/RecordBuilders/ExampleBlob.php new file mode 100644 index 00000000000..367f4ca65e1 --- /dev/null +++ b/plugins/ExamplePlugin/RecordBuilders/ExampleBlob.php @@ -0,0 +1,75 @@ +getLogAggregator()->queryVisitsByDimension(['idvisitor']); + * while ($row = $query->fetch()) { + * $label = $row['idvisitor']; + * unset($row['idvisitor']); + * $record->sumRowWithLabel($label, $row); + * } + * + * return [self::EXAMPLEPLUGIN_ARCHIVE_RECORD => $record]; + * ``` + * + * non-day periods will automatically be aggregated together + */ + protected function aggregate(ArchiveProcessor $archiveProcessor): array + { + $record = new DataTable(); + + $query = $archiveProcessor->getLogAggregator()->queryVisitsByDimension(['idvisitor']); + while ($row = $query->fetch()) { + $label = $row['idvisitor']; + unset($row['idvisitor']); + $record->sumRowWithLabel($label, $row); + } + + return [self::EXAMPLEPLUGIN_BLOB_RECORD_NAME => $record]; + } +} diff --git a/plugins/ExamplePlugin/RecordBuilders/ExampleMetric.php b/plugins/ExamplePlugin/RecordBuilders/ExampleMetric.php index e1f62aac45e..293cc462921 100644 --- a/plugins/ExamplePlugin/RecordBuilders/ExampleMetric.php +++ b/plugins/ExamplePlugin/RecordBuilders/ExampleMetric.php @@ -57,12 +57,16 @@ public function getRecordMetadata(ArchiveProcessor $archiveProcessor): array * to process daily reports. this code for example, uses idvisitor to group results: * * ``` - * $visitorMetrics = $this - * ->getLogAggregator() - * ->getMetricsFromVisitByDimension('idvisitor') - * ->asDataTable(); - * $visitorReport = $visitorMetrics->getSerialized(); - * return [self::EXAMPLEPLUGIN_ARCHIVE_RECORD => $visitorReport]; + * $record = new DataTable(); + * + * $query = $archiveProcessor->getLogAggregator()->queryVisitsByDimension(['idvisitor']); + * while ($row = $query->fetch()) { + * $label = $row['idvisitor']; + * unset($row['idvisitor']); + * $record->sumRowWithLabel($label, $row); + * } + * + * return [self::EXAMPLEPLUGIN_ARCHIVE_RECORD => $record]; * ``` * * non-day periods will automatically be aggregated together diff --git a/plugins/ExamplePlugin/RecordBuilders/ExampleMetric2.php b/plugins/ExamplePlugin/RecordBuilders/ExampleMetric2.php index 4aa5a3fe503..e3cf6a3285e 100644 --- a/plugins/ExamplePlugin/RecordBuilders/ExampleMetric2.php +++ b/plugins/ExamplePlugin/RecordBuilders/ExampleMetric2.php @@ -45,12 +45,16 @@ public function getRecordMetadata(ArchiveProcessor $archiveProcessor): array * to process daily reports. this code for example, uses idvisitor to group results: * * ``` - * $visitorMetrics = $this - * ->getLogAggregator() - * ->getMetricsFromVisitByDimension('idvisitor') - * ->asDataTable(); - * $visitorReport = $visitorMetrics->getSerialized(); - * return [self::EXAMPLEPLUGIN_ARCHIVE_RECORD => $visitorReport]; + * $record = new DataTable(); + * + * $query = $archiveProcessor->getLogAggregator()->queryVisitsByDimension(['idvisitor']); + * while ($row = $query->fetch()) { + * $label = $row['idvisitor']; + * unset($row['idvisitor']); + * $record->sumRowWithLabel($label, $row); + * } + * + * return [self::EXAMPLEPLUGIN_ARCHIVE_RECORD => $record]; * ``` * * non-day periods will automatically be aggregated together