getDataArray(); $dataArrayTwoLevels = $array->getDataArrayWithTwoLevels(); $subtableByLabel = null; if (!empty($dataArrayTwoLevels)) { $subtableByLabel = array(); foreach ($dataArrayTwoLevels as $label => $subTable) { $subtableByLabel[$label] = Piwik_DataTable::makeFromIndexedArray($subTable); } } return Piwik_DataTable::makeFromIndexedArray($dataArray, $subtableByLabel); } /** * Helper function that returns an array with common statistics for a given database field distinct values. * * The statistics returned are: * - number of unique visitors * - number of visits * - number of actions * - maximum number of action for a visit * - sum of the visits' length in sec * - count of bouncing visits (visits with one page view) * * For example if $dimension = 'config_os' it will return the statistics for every distinct Operating systems * The returned array will have a row per distinct operating systems, * and a column per stat (nb of visits, max actions, etc) * * 'label' Metrics::INDEX_NB_UNIQ_VISITORS Metrics::INDEX_NB_VISITS etc. * Linux 27 66 ... * Windows XP 12 ... * Mac OS 15 36 ... * * @param string $dimension Table log_visit field name to be use to compute common stats * @return Piwik_DataArray */ public function getMetricsForDimension($dimension) { if (!is_array($dimension)) { $dimension = array($dimension); } if (count($dimension) == 1) { $dimension = array("label" => reset($dimension)); } $query = $this->getLogAggregator()->queryVisitsByDimension($dimension); $metrics = new Piwik_DataArray(); while ($row = $query->fetch()) { $metrics->sumMetricsVisits($row["label"], $row); } return $metrics; } protected function aggregateCoreVisitsMetrics() { $query = $this->getLogAggregator()->queryVisitsByDimension(); $data = $query->fetch(); $metrics = $this->convertMetricsIdToName($data); $this->insertNumericRecords($metrics); return $metrics; } protected function convertMetricsIdToName($data) { $metrics = array(); foreach ($data as $metricId => $value) { $readableMetric = Metrics::$mappingFromIdToName[$metricId]; $metrics[$readableMetric] = $value; } return $metrics; } protected function compute() { Piwik_PostEvent('ArchiveProcessing_Day.compute', array(&$this)); } }