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 { $records = []; $callCount = $this->getAndIncrementArchiveCallCount($archiveProcessor); $metricValue = $callCount > 0 ? 1 : 0; $records[self::EXAMPLEPLUGIN_CONST_METRIC_NAME] = $metricValue; return $records; } private function getAndIncrementArchiveCallCount(ArchiveProcessor $archiveProcessor) { $params = $archiveProcessor->getParams(); $optionName = 'ExamplePlugin.metricValue.' . md5($params->getSite()->getId() . '.' . $params->getPeriod()->getRangeString() . '.' . $params->getPeriod()->getLabel() . '.' . $params->getSegment()->getHash()); $value = (int) Option::get($optionName); Option::set($optionName, $value + 1); return $value; } }