/** * Gets the archive id of every Single archive this archive holds. This method * will launch the archiving process if appropriate. * * @param array $metrics The requested archive metrics. * @throws Exception * @return array */ private function getArchiveIdsAfterLaunching($metrics) { // collect the individual report names for the requested metrics $reports = array(); foreach ($metrics as $metric) { $report = Piwik_Archive_Single::getRequestedReportFor($metric); $reports[$report] = $metric; } // process archives for each individual report $archiveIds = array(); foreach ($reports as $report => $metric) { // prepare archives (this will launch archiving when appropriate) foreach ($this->archives as $archive) { // NOTE: Piwik_Archive_Single expects a metric here, not a report $archive->setRequestedReport($metric); $archive->prepareArchive(); } // collect archive ids for archives that have visits foreach ($this->archives as $archive) { if (!$archive->isThereSomeVisits) { continue; } $archiveIds[] = $archive->getIdArchive(); if ($this->getNumericTableName() != $archive->archiveProcessing->getTableArchiveNumericName()) { throw new Exception("Piwik_Archive_Array_IndexedBySite::getDataTableFromNumeric() algorithm won't work if data is stored in different tables"); } } } return $archiveIds; }