Beispiel #1
0
 /**
  * Gets the archive id of every Single archive this archive holds. This method
  * will not launch the archiving process.
  * 
  * @param string  $metrics  The requested archive metrics.
  * @return array
  */
 private function getArchiveIdsWithoutLaunching($metrics)
 {
     $firstArchive = $this->getFirstArchive();
     $segment = $firstArchive->getSegment();
     $period = $firstArchive->getPeriod();
     // the flags used to tell how the archiving process for a specific archive was completed,
     // if it was completed
     $doneFlags = array();
     foreach ($metrics as $metric) {
         $done = Piwik_ArchiveProcessing::getDoneStringFlagFor($segment, $period, $metric);
         $donePlugins = Piwik_ArchiveProcessing::getDoneStringFlagFor($segment, $period, $metric, true);
         $doneFlags[$done] = $done;
         $doneFlags[$donePlugins] = $donePlugins;
     }
     $allDoneFlags = "'" . implode("','", $doneFlags) . "'";
     // create the SQL to query every archive ID
     $nameCondition = "(name IN ({$allDoneFlags})) AND\n\t\t\t\t\t\t  (value = '" . Piwik_ArchiveProcessing::DONE_OK . "' OR\n\t\t\t\t\t\t   value = '" . Piwik_ArchiveProcessing::DONE_OK_TEMPORARY . "')";
     $sql = "SELECT idsite,\n\t\t               MAX(idarchive) AS idarchive\n\t\t          FROM " . $this->getNumericTableName() . "\n\t\t         WHERE date1 = ?\n\t\t           AND date2 = ?\n\t\t           AND period = ?\n\t\t           AND {$nameCondition}\n\t\t           AND idsite IN (" . implode(',', array_keys($this->archives)) . ")\n\t\t      GROUP BY idsite";
     $bind = array($period->getDateStart()->toString('Y-m-d'), $period->getDateEnd()->toString('Y-m-d'), $period->getId());
     // execute the query and process the results.
     $archiveIds = array();
     foreach (Piwik_FetchAll($sql, $bind) as $row) {
         $archiveIds[] = $row['idarchive'];
     }
     return $archiveIds;
 }