getParams()->getArchiveOnlyReport(); if ($requestedReport) { $processor->getParams()->setIsPartialArchive(true); } $this->createSequence(); } public function aggregateDayReport() { /** * inside this method you can implement your LogAggreagator usage * to process daily reports, this one uses idvisitor to group results. * * $visitorMetrics = $this * ->getLogAggregator() * ->getMetricsFromVisitByDimension('idvisitor') * ->asDataTable(); * $visitorReport = $visitorMetrics->getSerialized(); * $this->getProcessor()->insertBlobRecord(self::EXAMPLEPLUGIN_ARCHIVE_RECORD, $visitorReport); */ 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); $date = $this->getProcessor()->getParams()->getPeriod()->getDateStart(); $differenceInSeconds = $daysFrom->getTimestamp() - $date->getTimestamp(); $differenceInDays = round($differenceInSeconds / 86400); $this->getProcessor()->insertNumericRecord(self::EXAMPLEPLUGIN_METRIC_NAME, $differenceInDays); } if ($this->isRequestedReport(self::EXAMPLEPLUGIN_CONST_METRIC_NAME)) { $callCount = $this->getAndIncrementArchiveCallCount(); $metricValue = $callCount > 0 ? 1 : 0; $this->getProcessor()->insertNumericRecord(self::EXAMPLEPLUGIN_CONST_METRIC_NAME, $metricValue); } } public function aggregateMultipleReports() { /** * Inside this method you can simply point daily records * to be summed. This work for most cases. * However if needed, also custom queries can be implemented * for periods to achieve more acurrate results. * * $this->getProcessor()->aggregateDataTableRecords(self::EXAMPLEPLUGIN_ARCHIVE_RECORD); */ $reports = []; if ($this->isRequestedReport(self::EXAMPLEPLUGIN_METRIC_NAME)) { $reports[] = self::EXAMPLEPLUGIN_METRIC_NAME; } if ($this->isRequestedReport(self::EXAMPLEPLUGIN_CONST_METRIC_NAME)) { $reports[] = self::EXAMPLEPLUGIN_CONST_METRIC_NAME; } $this->getProcessor()->aggregateNumericMetrics($reports); } private function incrementArchiveCount() { $sequence = new Sequence('ExamplePlugin_archiveCount'); $result = $sequence->getNextId(); return $result; } private function createSequence() { } private function getAndIncrementArchiveCallCount() { $params = $this->getProcessor()->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; } }